5

I'm 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'm only getting 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 header "X-Token" (received if I check in the browser console)

Any idea to receive the complete headers list from Angular and $resource?

tezqa
  • 139
  • 8

1 Answers1

3

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

Access-Control-Expose-Headers: X-Token, header-a
Muhammad Reda
  • 26,379
  • 14
  • 93
  • 105