Reputation: 5129
Basically the title has described everything. I send an api call, get a response, with Authorization
in the header, and I want to retrieve this authorization token from the header because it is needed for subsuquent api calls. How should I get this info?
Upvotes: 2
Views: 2305
Reputation: 1231
You should take a look here: https://docs.angularjs.org/api/ng/service/$http
$http.get('yourUrl').
success(function(data, status, headers, config) {
console.log(headers);
})
Upvotes: 1
Reputation: 54741
$http
passes headers
to the success/error callbacks. The headers
parameter is a function that takes a single argument that is an array. It returns all those header values as an array result.
$http.get('/someUrl')
.success(function(data, status, headers) {
console.log(headers(['Authorization']));
});
Upvotes: 0