Within the code snippet below, there exists a for loop where an API call is made. The intention is to have the 1st API call complete and execute all the subscribed code before moving on to the next iteration of the loop, triggering another API call.
Currently, the APIs are running concurrently rather than sequentially as desired.
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';
}
}
)
});
Despite searching through various stackoverflow threads, I have yet to find a suitable solution tailored to my specific scenario. Any assistance would be greatly appreciated.