简体   繁体   中英

How to access HTTP headers of request in AngularJS

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM