I have a http get request to get a list of some items from a feed. the feed API requires a page param, which is limited to 20. I would like to get first 60 instead, so I need to make 3 requests
requestOptions.params.set('page', 1);
this.http.get(environment.api+ '.feed.json', requestOptions)
requestOptions.params.set('page', 2);
this.http.get(environment.api+ '.feed.json', requestOptions)
requestOptions.params.set('page', 3);
this.http.get(environment.api+ '.feed.json', requestOptions)
what is the best way to deal with it to get an ordered list? I am not very fond of nesting
Your service:
Somewhere where you call the service
Object.forkJoin
will wait until all requests are completed and then you can build a single list with this results;There are many ways you can do this. I normally use
Observable.forkjoin or Observable.merge
you can do this in below ways. Adjust the code little to run