While working in TypeScript, I encountered a scenario where I needed to loop through a list using a for loop and make an HTTP request for each array element to fetch its details. However, due to the time-consuming nature of this operation, I always ran into an error stating that there were no details available. Is there a way to process each detail immediately after it is returned from the HTTP request without waiting for the entire array loop to finish?
this.allAnalysisData.forEach((analysis) => {
this.analysisCenterService.getAnalysisDetails(analysis.id).subscribe(detail => {
this.detailed.push({Analysis: analysis, det: detail});
});
});