Why isn't my API adding items to my cart in my online store?

Why isn't my API adding items to my cart in my online store?

rodito
Shopify Partner
5 0 0

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 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
 
Replies 0 (0)