In the below code, I have a for loop inside that one API is getting called. I want the 1st API call to be finished and code inside subscribe fully executes first and then the next iteration of for loop will begin and again the API call will be triggered for the next iteration.
But currently the APIs are executing in parallel mode. But I want the APIs to be executed in sequential manner.
parentLevelIdArray.forEach(parentLevelId => {
this.locModService.deleteAPI(parentLevelId, levelObj.id)
.subscribe((response) => {
if (response.status === 200) {
this.message = 'Image uploaded successfully';
this.getSublevels();
this.getAllLinkedLevel();
} else {
this.message = 'Image not uploaded successfully';
}
}
)
});
I have checked other stackoverflow links but didn't get the actual answer for my case. Please help.