[ { "product-id": "16", "quantity": "5", "price": "25.000" }, { "product-id": "17", "quantity": "7", "price": "84.000" }, { "product-id": "15", "quantity": "10", "price": "100.000" }]
const products = [
{
"product-id": "16",
"quantity": "5",
"price": "25.000"
},
{
"product-id": "17",
"quantity": "7",
"price": "84.000"
},
{
"product-id": "15",
"quantity": "10",
"price": "100.000"
}
];
const apiUrl = 'https://yourdomain.com/api/products';
fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(products)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));