App reviews, troubleshooting, and recommendations
Hi
I am working on some custom code and found when i am making ajax post call it gives 404 error
Need to call this section and get data is my primary concern.
simple ajax with post call gives 404 error though website page/section is working perfectly.
Error: https://prnt.sc/59wqwAGtBopm
Working url: https://theearthbands.com/?sections=johntest
Below is demo code which is not working it is as simple as to work so that i can apply my logic to others
const endpointUrl = '/?sections=johntest';
const apiKey = 'key added'; // Replace with your actual API key
$('#calculatorForm').on('click', function() {
const dataToSend = {
key1: 'value1',
key2: 'value2'
};
fetch(endpointUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}` // Include the authorization header
},
body: JSON.stringify(dataToSend)
})
.then(response => response.json())
.then(responseData => {
console.log('Response:', responseData);
})
.catch(error => {
console.error('Error:', error);
});
});
Help is much appreciated
Section rendering API does not require authorization and you can't pass any data, so there is no need to POST.
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024