Мое обещание Axios не работает должным образом.Я думаю, что выполнение начинается внутри цикла forEach
.Я хочу, чтобы выполнение axios начиналось только после batch.commit
aMobileNumbers.forEach(function(iMobileNumber) {
promises.push(axios.post('https://example.com', {
'app_id' : "XXXXXXX-7595",
'contents' : { "en":`${sText}` },
})
.then((response) => console.log(response.data))
.catch((response) => console.log(response))
);
})
console.log(`#${context.params.pushId} Promises: `, promises);
return batch.commit().then(() => {
console.log(`wrote`);
return axios.all(promises); //<--- doesnot execute here
})
.then(() => db.doc(`/MGAS/${context.params.pushId}`).delete())
.then(() => console.log(`Deleted the MQ`))
.catch((error) => console.log(`#${context.params.pushId} ${error}`));