How to get full response headers from angular resource

I am sending a request with an Angular $ resource:

myResource.get({ foo: bar }, function success(data, headers) { console.log("data:", data); // Prints data console.log("headers:", headers()); // Prints only few headers }, function failure(response, status) { // Handling failure here... }) 

But I get only a few headers:

 {content-type: "application/json", cache-control: "no-cache, max-age=604800", expires: "Mon, 06 Apr 2015 16:21:17 GMT"} 

when I want to catch the "X-Token" header (received if I register the browser console)

Any idea on getting a complete list of headers from Angular and $ resource?

+5
source share
1 answer

For security reasons, some response headers are not displayed by default. So, you need to use Access-Control-Expose-Headers on the server and add additional response headers that you want to return.

 Access-Control-Expose-Headers: X-Token, header-a 
+3
source

Source: https://habr.com/ru/post/1216473/


All Articles