0

What is the 'Angular' way to retrieve incoming request headers? I'm not asking how to set headers in the request or response of an Angular Application.

For example in the following request, How to retrieve the token header within my Angular controller:

curl 'http://localhost:3000/index.html' -H 'token: mytoken'
cdvel
  • 1,334
  • 10
  • 10
  • I strongly suspect that this isn't an angular function. How would you do it using ordinary Javascript? – Robert Harvey Mar 14 '16 at 05:35
  • That's obviously not an angular function. My question is towards, How would you retrieve a particular header from within an Angular 'function'. Imagine this curl is pointing to my angular application, how do you get the 'token' header? – cdvel Mar 14 '16 at 05:46
  • The same way you would do it using ordinary Javascript. – Robert Harvey Mar 14 '16 at 05:47
  • Is that the Angular way? – cdvel Mar 14 '16 at 05:48
  • There is no Angular way. The purpose of Angular is to provide MVVM facilities to a browser for frontend data binding yada yada. It has nothing to say about browser headers, except insofar as it may or may not use some for its own purposes. – Robert Harvey Mar 14 '16 at 05:49
  • Willing to try, what would that be? – cdvel Mar 14 '16 at 05:50
  • http://stackoverflow.com/questions/220231/accessing-the-web-pages-http-headers-in-javascript – Robert Harvey Mar 14 '16 at 05:51
  • I saw that. That captures a response header. Not a request. Please read the question carefully. Incoming request. Say I have an angular app running, I run that curl pointing to it. How do you get the token header? – cdvel Mar 14 '16 at 05:54
  • Are you referring to an authorization token header? – Robert Harvey Mar 14 '16 at 05:56
  • yeah. that for example, or a language header – cdvel Mar 14 '16 at 05:57

0 Answers0