How to use Predictive Search code example?

Highlighted
Shopify Partner
12 0 1

On this page https://shopify.dev/tutorials/add-predictive-search-to-your-shopify-theme#example-using-predictive-s... the first line of the code example goes

 

import PredictiveSearch from "@shopify/theme-predictive-search";

How do I use this line in my code? Because if I put this line in my theme.js file, there will an error saying import can't be used out of a module.

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
1041 140 167

Hey @shenkwen 

 

This assumes you're using a build tool to import the library. Alternatively, try these examples.

Notice; Out of office, replies will be delayed until my return. Thanks!
0 Likes
Highlighted
Shopify Partner
12 0 1

Thanks. I was able to get correct response from that API. 

Regarding the building tool, I'd like to know more about this. Because the doc writer didn't explain it, I guess it is some well-known information I am missing here. I heard of building tools before but never really dived into it. For learning purposes, can you show me what building tool I can use here and make this code example work in my code? Thank you!

0 Likes
Highlighted
Explorer
88 7 21

@shenkwen 

Hey Shenkwen, 

can you explain how you managed to get a response, step by step, so that there will be more clarity for me how to start? Where exactly did you copy what code? This would be an incredible help!!

Thank you!!!

Simonski

0 Likes