const documents = null; var loadDocuments = function () { fetch("/static/search.json") .then((response) => { if (!response.ok) { throw new Error("Failed to load search index."); } return response.json(); }) .then((response) => (this.documents = response)) .catch((error) => console.error(error)); }; let miniSearch = new MiniSearch({ fields: ["title", "body"], storeFields: ["title", "url"], }); loadDocuments(); console.log(documents); miniSearch.addAll(documents);