【发布时间】:2021-07-11 15:28:50
【问题描述】:
我正在使用 axios 发布数据,我想要来自响应标头的授权令牌。
await axios.post('authenticate', {
params: {
one: this.one,
two: this.two,
},
}).then((res) => { console.log(res.config.headers.authorization); }); # returns Bearer null
当我查看“网络”选项卡并且发布请求在响应标头中具有承载值并且在请求标头中具有“Bearer null”时,我收到了选项和发布响应。我显然只从res 获取请求标头,我不知道如何获取响应标头授权值。 res.headers 根本没有 Authorization 属性。只有这个:
{
"cache-control": "no-cache, no-store, max-age=0, must-revalidate",
"content-length": "0",
"expires": "0",
"pragma": "no-cache"
}
如何访问响应标头的授权值?
【问题讨论】:
标签: axios request response vuejs3