Reputation: 455
Brand noob at this and have gotten one post request working but hoping to chain several and process the response. I gather the way to do this is forkJoin(), however I am not getting the responses (although I see the requests and responses in the Network) and don't really get how to do the composition. I think I may need to subscribe to them?
const requests: Array<Observable<AjaxResponse>> = [];
fields.forEach((field: string) => {
const request: AjaxRequest = generateRequest(field);
requests.push(Observable.ajax(request));
});
Observable.forkJoin(requests).map(
responses => { // never stops here
responses.map((res, idx) => { // or here
})
});
Upvotes: 0
Views: 105
Reputation: 455
Found it about 10 mins later
const forkJoin = Observable.forkJoin(requests);
forkJoin.subscribe(ajaxResponses => {
});
Upvotes: 1