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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With