function SendObj(id, language) {
setObjSending(true);
Promise.all(
objBoxes.map((box) => {
return axios
.post('/panel/subtask/paint-object/', {
language: language,
details: 'paint object',
sub_task_paint: id,
sub_task_color: [box.colorId],
image_name: box.image_name,
})
.catch(() => setObjSending(false));
})
)
.then(() => {
message.success('subtask saved!');
history.goBack();
});
}
The above function makes the produced Ids in database to be not in order of box indexes. Is there a way to do the axios call sequentially to fix this?