Reputation: 2255
I'm having a problem with AngularJS's $http service not returning all of the headers from the API I'm polling. Here's what I've got:
$http({
method: 'POST',
withCredentials: true,
url: 'http://api.mydomain.com/query',
data: JSON.stringify(parameters)
})
.success(function(data, status, headers, config){
... // setting some scope parameters based on data
console.log(headers());
})
I can tell through the network tab in Chrome that a bunch of response headers are being returned by the API (I'm particularly interested in the X-Pagination-Total-Items header).
Here's a screenshot of the network tab from the request:
But the console.log statement above (which should output all headers) only returns two:
Any idea what's going on? How do I actually access all of the headers coming back from the AJAX call?
Thanks,
-Nate
Upvotes: 37
Views: 9665
Reputation: 2255
Turns out that the Access-Control-Expose-Headers cannot accept a wildcard. We needed to specify exactly which headers the client should have access to, and then it worked.
Upvotes: 61