I need to call ascync operations in a loop:
for (var i = 0; i < message.destinatarios.length; i++) {
messageList.push(this.sms.send(destinatario.numero_celular, string));
// this will take a litle time to be executed
}
// Here I need something to be fired each time one of the promises in messageList is resolved
Promise.all(messageList)
.then(res => {
//that is executed when all the promises have been resolved
})
.catch(err => {
// that is executed when some of then fail
});
Then for each response I need to increment a counter like this
console.log("processing " + counter++ + " of " + messageList.length);
How would I do that in correct way since I need to wait for all promises to be fufilled until moving to the next step?