David Coelho
David Coelho

Reputation: 153

Save token that comes in response to Api

I'm trying to save the token that my server sends on every request. Although apparently "Authorization" is present in the response, I can not print the value.

The code is: ionic2

The server returns: enter image description here

What I can print to the console: enter image description here

On the server I'm using a middleware for cors: enter image description here

How can I get the token that is coming from Header Authorization?

Upvotes: 0

Views: 255

Answers (1)

Karim
Karim

Reputation: 8632

it looks that you did not expose the header correctly, the browser will not forward this header to your code unless you specify it.

try adding this to you $headers object

'Access-Control-Expose-Headers' => 'Authorization'

Upvotes: 1

Related Questions