Hi I want to fetch the products that exist in cart for that I am using Js code that checks all the products added in crt page
fetch(‘/cart.js’)
.then(response => response.json())
.then(cart => {
// Loop through each item in the cart
cart.items.forEach(item => {
// Get the product information from Shopify’s AJAX API
fetch(/admin/api/2023-01/products/${item.product_id}.json)
.then(response => response.json())
.then(product => {
// Log the product’s metafields to the console
console.log(product);
});
});
});
I am using this code but this code gives me 301 redirect error.
The reason I found is that cart.js request send to .myshopify.com domain that is now not primary domain . My original domain is for example furnace.ca that’s why it gives me 301 redirect in response in developer network tab .
Can anyone have solution to this issue . Problem is related to domain redirection
Thanks