I have the following code:
var arrayAxios = [];
const array = async() => {
await sleep(3000);
_.forEach(tasks, task => {
let res = _.includes("selected", task.value);
if (res) {
this.axios
.get(url, { params: { data1 } })
.then(response => {
arrayAxios.push(this.axios.post(url, { dataAAA }));
});
}
});
};
var promises = async() => {
const arrayAxios = await array();
await Promise.all(arrayAxios)
.then(response => {
resetAll_dataAAA(); // <--- my dataAAA in arrayAxios are reset before post in Promise.all!
})
.catch(error => {
console.log(error);
});
};
promises();
The function "resetAll_data()" is executed before the data is post into the DDBB. I can't find the problem.
Any suggestions?
Thank you very much!
sleep(3000)call?arrayAxios(the one insidepromises) isundefinedbecausearraydoesn't return anything