I have following code in Angular 8:
fetchMedia() {
this.mediaDetails.forEach(entry => {
this.fetchSingleMedia(entry); // NEED TO MAKE THIS SEQUENTIAL
}
});
}
fetchSingleMedia(entry) {
this.mediaService.getMedia(entry).subscribe(
(data) => {
// MY LOGIC HERE
},
error => {}
);
}
The fetchSingleMedia method is used by other parts of the code as well. I want to keep the Logic in fetchSingleMedia itself
Now, if I have to sequentially make multiple requests to fetchSingleMedia method, how do I need to modify the fetchSingleMedia method and way of calling it? maybe using async/await/promise or rxjs?
Edit:
With concat, second request is sent before first's response is received. I want second request to go after first request's response is received