I am using json-server
at localhost:3000
. it is working fine and I am able to get data in Angular http.get
. I want to read response header X-Total-Count
, inside angular .subscribe. But I can't see that property in the response header. But Chrome console shows that X-Total-Count: 16
.
this.catgoryItems.getAllServices(
{
_page: pageIndex || this.pageIndex,
_limit: limit || this.limit
})
.subscribe((response: any) => {
console.log(response);
this.dataSource = response.body;
}, err => {
console.log(err);
this.alertService.showError('Error, plz try again later');
});
Observe response and access headers
http
.get<any>('url', {observe: 'response'})
.subscribe(resp => {
console.log(resp.headers.get('X-Total-Count'));
});