Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hello there,
I got 500 internal server error when using post cart add.js.
I wrote like that page, Example API calls.
https://shopify.dev/api/ajax/reference/cart
Could you tell me how to fix?
my code is
fetch(window.Shopify.routes.root + 'cart/add.js', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(toSend)
})
.then(response => {
console.log(response.status);
response.json;
})
.then(data => {
console.log(data);
})
.catch((error) => {
console.log('error:', error);
});
Solved! Go to the solution
This is an accepted solution.
Sorry, I found the mistake...
that was 'toSend'. toSend has to be the array.
This is an accepted solution.
Sorry, I found the mistake...
that was 'toSend'. toSend has to be the array.