[ { "add-products": [
{ "0": { "product-id": "16", "quantity": "5", "price": "25.000" } },
{ "1": { "product-id": "17", "quantity": "7", "price": "84.000" } },
{ "2": { "product-id": "15", "quantity": "10", "price": "100.000" } } ] },
{
"product-name": "0",
"quantity": "0",
"price": "0",
"object_id": "31"
}
]
const data = [
{
"add-products": [
{
"0": {
"product-id": "16",
"quantity": "5",
"price": "25.000"
}
},
{
"1": {
"product-id": "17",
"quantity": "7",
"price": "84.000"
}
},
{
"2": {
"product-id": "15",
"quantity": "10",
"price": "100.000"
}
}
]
},
{
"product-name": "0",
"quantity": "0",
"price": "0",
"object_id": "31"
}
];
const apiUrl = 'https://your-api-endpoint.com';
fetch(apiUrl, {
method: 'POST',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json'
}
}).then(response => {
return response.json();
}).then(data => {
console.log(data);
});