Shopify themes, liquid, logos, and UX
Hello There,
I'm getting 500 Internal Server Error when adding products using a Cart AJAX API(/cart/add.js).
Can anyone help me to fix this issue?
Below is the code which I'm using:
let $th_id_array = new Array();
$th_id_array.push({ id: 123, quantity: 1, });
const $th_bundle_formData = {items: $th_id_array};
fetch('/cart/add.js', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify($th_bundle_formData)
}).then(response => response.json()).then($th_addtocart_result => {
if($th_addtocart_result.items.length > 0){
console.error($th_addtocart_result);
}
}).catch(($th_addtocart_error) => {
console.error($th_addtocart_error);
});
Hey @WebContrive ,
If you open up the Developer Tools in your browser, open the Network tab and click into the request that is failing you should be able to see the reason why.
Hello @Matt-Pipelabs,
Thank you so much for your quick response.
I have checked the Network tab and it is also showing the same error (500 Internal Server Error).
Are you ready to take your business to the next level? Look no further than the latest ...
By SarahF_Shopify Apr 15, 2024We’re keeping the ball rolling to make sure you’re always ahead of the game. So buckle ...
By JasonH Apr 8, 2024Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024