I have a GET request that I need to make. The thing is that each request only returns a page of 50 data entries so there can be multiple pages of data that can only be retrieved with different requests. I have to wait for all the data to be grabbed so that I can then process the data as a whole
I need to do something like"
for(var i = 1; i <= numPages; ++i){
this.http.get(url, httpOptions).subscribe((information: any =>{
allInfo.push(information);
});
}
processData(allInfo);
where the url
will be updated with the correct page.
I know that a processData
will execute before the for loop finishes. Is there someway to incorporate promise
and then
statements or maybe a pipe
to get all the data pushed to the allInfo
array so that it can then be processed?