Rich
Rich

Reputation: 1051

accessing response header via Axios

I'm using Axios to make a secure POST call to an API. This returns an URL within the response headers under 'Location'.

I can see the URL being populated within Chrome's dev tools:

enter image description here

but the response inside JS from Axios (below) doesn't contain this information:

enter image description here

Any advice greatly received!

Upvotes: 5

Views: 9141

Answers (1)

rcarubbi
rcarubbi

Reputation: 123

Possibly it occurs because you are doing a cors request that doesn't expose location header by default.

You need to add this Cors Configuration to your server side app.

Access-Control-Expose-Headers: Location

as you can see here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers

Upvotes: 2

Related Questions