import PredictiveSearch from "@shopify/theme-predictive-search"; var predictiveSearch = new PredictiveSearch({ resources: { type: [PredictiveSearch.TYPES.PRODUCT], limit: 4, options: { unavailable_products: PredictiveSearch.UNAVAILABLE_PRODUCTS.LAST, fields: [ PredictiveSearch.FIELDS.TITLE, PredictiveSearch.FIELDS.VENDOR, PredictiveSearch.FIELDS.PRODUCT_TYPE, PredictiveSearch.FIELDS.VARIANTS_TITLE ] } } }); // Set success event listener predictiveSearch.on("success", suggestions => { const productSuggestions = suggestions.resources.results.products; if (productSuggestions.length > 0) { const firstProductSuggestion = productSuggestions[0]; alert(`The title of the first product suggestion is: ${firstProductSuggestion.title}`); } }); // Set error event listener predictiveSearch.on("error", error => { console.error("Error message:", error.message); }); // Send query predictiveSearch.query("The Calling");