How can I make my code run sequentially? For example,
If I have a for loop which gets some data from a service, I want the n+1 iteration to run
n+1
SomeMethod(i, length){ If(i< length){ this.dataService.get(i).subscribe( data => { // do some business logic this.SomeMethod(i+1, length); }); }else{ console.log("Iteration completed"); }}
Try this logical way