I am attempting to build an order tracker on my Hydrogen store
The order tracker should take an email and an order ID and then use those values to find the corresponding order
const response = await fetch(`https://${publicDomain}/admin/api/2024-01/orders.json?name=1001}`, {
method: "GET",
headers: {
"X-Shopify-Access-Token": token,
"Content-Type": "application/json"
}
});
I then need to display this order to the customer
Hi @josh_rogers1310 , I think you can do it by creating a custom app to query the customer by email, after that you can retrieve all orders belonging to the customer and display the order details with the corresponding ID. You can send me a message if you need further support: https://weaverse.io/contact.
@Weaverse - thank you for your reply
Would you be able to elaborate a bit more please on my hydrogen storefront would ‘reference’ or speak to the app. As the app is what has more access than the hydrogen build how do I safely perform a FETCH from within the app without exposing the API token and then pass that data returned in to a page on my hydrogen storefront?
Any further help, advice or examples would be much appreciated
When using Hydrogen, which is a framework based on Remix, you have complete control over both the frontend and the backend. You can securely store the API key in the ENV and then use it in the loader/action function, which runs from the backend. This ensures that all fetch actions are safe and secure.
You can read more about fetching external data here: https://shopify.dev/docs/custom-storefronts/hydrogen/data-fetching/third-party