How to access a specific header from an http response?

5

I have a Rest API in Java, which makes use of JWT to authenticate users and generate tokens to access their resources. I have an application in AngularJS, which should consume these resources, but I must first request a token in the API. I would like to know how I can access the token that is in the POST request response header. By the Angular I am not getting access to this, however, in the browser I can see the token in the response of the request.

    
asked by anonymous 26.08.2017 / 14:01

1 answer

3
$http.post('/login', user).then(function(response) {
    var authorization = response.headers('Authorization');
});

With the headers () function you can access any of the header attributes.

    
28.08.2017 / 04:20