1

I know I can access an HTTP request's GET parameters in AngularJS with

$location.search().parameterOfInterest

But how do I access HTTP headers of the request?

I'm not using $http here. I'm asking about request to an AngularJS web page.

This question and answers makes me believe this is could be not possible: Accessing the web page's HTTP Headers in JavaScript

divanov
  • 6,173
  • 3
  • 32
  • 51
  • Could you please tell us more information? What do you want to do? There are others ways to send data. So, why do you need use that headers? – Oscar López Feb 19 '19 at 15:16
  • Well, the context is not relevant here. My question is that if I can access headers in JavaScript and/or AngularJS or not. – divanov Feb 19 '19 at 15:43

1 Answers1

0

You can use a request interceptor that is called with an HTTP configuration object. An HTTP configuration object has a header property that you can freely access / modify inside your interceptor.

The response object of promise also has a header property that you can access.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
NTP
  • 4,338
  • 3
  • 16
  • 24