I have a api-rest for add item from external site to my store in shopify, but not working, error 400, here my code:
app.post(‘/cart’, async (req, res) => {
let formData = {
‘items’: [{
‘id’: 7070227824751,
‘quantity’: 1
}]
};
const apiUrl = ‘https://mystore.myshopify.com/cart/add.js’;
const axiosConfig = {
headers: {
‘Content-Type’: ‘application/json’,
‘X-Shopify-Access-Token’: shopifyConfig.accessToken,
‘Authorization’: Basic ${Buffer.from(${shopifyConfig.apiKey}:${shopifyConfig.password}).toString('base64')}
},
body: JSON.stringify(formData)
};
try {
const response = await axios.post(apiUrl, axiosConfig);
res.json(response);
const allProducts = response.data.products;
res.json(allProducts);
} catch (error) {
res.status(500).send({ error: ‘Internal Server Error’ });
}
});
I dont know what is wrong, please any help thanks