`How to get all Headers from Response?
S
S
Sergei Iamskoi2019-02-06 11:09:59
API
Sergei Iamskoi, 2019-02-06 11:09:59

How to get all Headers from Response?

I googled how to do it, following the example I did:

getData(page): Observable<any> {
    const url = `${this.url}?page=${page}`;
    return this.http.get<any>(url, {observe: 'response'});
  }

  loadData(page) {
    this.feedService.getData(page)
      .subscribe(data => {
        console.log(data.headers.keys());
        console.log(data.headers.get('X-Pagination-Page-Count'));
     });
  }

The server gives such headers, they can be seen in the Google Chrome network:
5c5a95ec353ef553234666.png
But Angular sees only 4 headers, the ones I need are missing. What's wrong?
5c5a961806c9e645942949.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
spnq, 2019-02-06
@syamskoy

Try adding a header 'access-control-expose-headers' : '<header-name>'to the API.
About the essence of your problem is here .
In short, by default, only 6 are open for receiving:

  • Cache-Control
  • Content-Language
  • content-type
  • Expires
  • Last Modified
  • pragma

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question