I created a plugin to select products from our ecommerce backend and created a component based on the components from the Shopify starter (component, resolver for data) using getAsyncProps. It works great in production and locally, but in the editor the data from getAsyncProps isn’t getting resolved.
getAsyncProps is meant to be used as a helper to fetch all the data required for rendering your components on the server-side (or during SSG) , but note that you’ll still need to fetch the required data inside your component in the case of client side rendering (for example when you’re editing in builder and the page re-renders on the browser and doesn’t make a round trip to the server).
Make sure you are fetching any necessary data within the component itself and see if that fixes your issue.
@gijsbotje Did fetching within your custom component work?
The issue I have with this solution is that we want to protect the API credentials from leaking out into the front end, not to mention we need to send a hostname header to our API for access.
@TimG how would we fetch data from the front end if we need a server to produce it? Seems really annoying to have a function like getAsyncProps that works great in production but there’s no automatic fallback for previewing.
Am I supposed to check for isPreviewing and then spin up my own server API proxy to get data just for preview? That seems a bit excessive…