How to hold for loop till inside funtion not complete?


#1

i have customer array. i want to upload one by one customer details from array.
How to hold for loop till upload methode return success or error msj. Till that i dont want to upload next customer from array? How to hold for loop ??

uploadAllOnce(){
     for(let i=0;i<this.customerArray.length;i++){
upload(this.customerArray[i]);
       
     }
  }
  

#2

I think this is generally a mistake, because what is ordinarily desired is actually for the uploads to either succeed or fail as a unit, in which case you don’t actually care about the ordering, and something like the forkJoin operator is pretty much exactly what you are looking for (and more efficient than what you are asking how to do).

If you insist on doing specifically what you ask about, look into the concatMap operator.