index.js
const data = [
{
id: 1,
name: 'John',
age: 25
},
{
id: 2,
name: 'Jane',
age: 30
}
];
data.forEach(item => {
fetch('http://localhost:3000/your-endpoint', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(item)
})
.then(response => response.json())
.then(result => {
console.log(result);
})
.catch(error => {
console.error(error);
});
});