I’m developing my first theme app extension, which will retrieve data from an endpoint and display the fetched results. I wasn’t able to find a similar example, so I’d like to confirm if the approach I’m planning to use is correct:
A JavaScript file will be included in the extension.
This JavaScript file will use the fetch method to retrieve data and update a specified DOM element with the response.
To ensure the request is authorized, proxy URLs will be used.
Is the approach above correct, or is there a more efficient solution?
and include storefront.js file in the assets folder where you’ll call the fetch method. This is called Shopify Theme UI App embeds, you may need to activate your app embeds from the Shopify theme editor.