0

I'm developing an angular application where authentication is being done by third party and will redirect to our app with some information in the http headers.

Questions:

  1. How can I retrieve the information in http headers in Angular 5?
  2. How can I also retrieve url's query string in Angular 5?

Thank you in advance.

Zorlac
  • 83
  • 1
  • 8

1 Answers1

0

Pass the option observe: 'response' to get an Observable<HttpResponse> object, from which you can read the headers.

Example:

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

See https://angular.io/guide/http#reading-the-full-response

Mike Jerred
  • 9,551
  • 5
  • 22
  • 42
  • Thanks for the response but I think this is when you are using HttpClient or Http. My question is regarding once the app is launched in the browser by putting its url (of course that's how you launch a web application in browser). How can I retrieve the http headers and query string of the application. – Zorlac May 10 '18 at 21:20
  • Ah, it looks like that is not possible, see: https://stackoverflow.com/questions/220231/accessing-the-web-pages-http-headers-in-javascript – Mike Jerred May 10 '18 at 21:49