When making a http.get()
to a REST API, metadata concerning page, page-count and total results are often returned in response headers.
Angular's HttpClient
parses and returns data based on the response.body
, and returns it in an Observable.
How then do you query the Response headers, and call the getter recursively until you've received the full dataset from the REST API?
Or do you build you own HttpClient using basic AJAX methods?
You can try something like this:
this._myService.getDocument(item.ID)
.subscribe(
(data) => {
this.doSomething(data);
},
error => { this.errorMessage = <any>error; },
() => { });
doSomething(data: HttpResponse<any>) {
let count = data.headers.get('count');
console.log(count);
}