I'm working with javascript and I want that wait for other function response before iterate next item.
Here is the desired behaviour:
let lista = [1,2,3,4]
console.log('Iteracion de la lista')
async function procesarLista(array){
for(const item of array){
console.log('-->START indice: ' + item)
//Simulate delay (for each iteration) of backend response
setTimeout(function(){
console.log('....waiting.... for : ' + item );
}, 2500);
console.log('-->FINISH indice: ' + item)
}
console.log('Done');
}
//Execute:
procesarLista(lista);
This is the WRONG result:

