accessing response header via Axios

眉间皱痕 提交于 2020-01-17 08:22:28

问题


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:

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

Any advice greatly received!


回答1:


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



来源:https://stackoverflow.com/questions/45037390/accessing-response-header-via-axios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!