How get the header of the first http request when I launch an angular app (http://localhost:4200/)

Viewed 777

I am looking to get the header of the first http request http://localhost:4200/

To launch my app, I go to the url http://localhost:4200/ and I want to write the header of the http entring, in the console.

Does anyone know if it is possible ?

I try use an interceptor but I intercept only the http request and response sorting of my app.

1 Answers

Angular HttpClient by default observes the result only, you can use {observe: 'response'} to get full response and get headers from the same.

 this.http.get('/', { observe: 'response' }).subscribe(response => {
    console.log(response.headers.get('SAMPLEITEM'))
 });

Documented here

Related