Issue
Before my page is rendered, I want to fetch data from 5 independent different APIs (there is no need to wait for the first in order to fetch the data from the second), and once all of them are complete, I want a boolean variable to be set. Something like this
http.get(url1).subscribe(response => {
// set response data
// & somehow notify that this call is complete?
});
http.get(url2).subscribe(response => {
// set response data
// & somehow notify that this call is complete?
});
...
How can I achieve that with Angular and RxJS?
Solution
simply use forkJoin
:
forkJoin([http.get(url1), http.get(url2)]).subscribe(dataAsArray => {
// do what you need with the data
})
Answered By - Eli Porush
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.