我试图从服务器访问x-auth
令牌。但我没有得到预期的结果。response.headers
来自服务器的控制台输出如下
Headers {
map: {
connection: "keep-alive"
content-type: "application/json; charset=utf-8"
x-auth: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiIxaXBpNG1laiIsImFjY2VzcyI6ImF1dGgiLCJpYXQiOjE1NTY3MDg1NTR9.cOXtbQO_n2vf-HwLmKwyzSi9QcFgh4SghfgCamcLyw4"
x-powered-by: "Express"
}
}
我试图安慰x-auth
,但我得到了错误auth is not defined
。但是当我安慰response.headers.map.connection
我得到了价值。以下是我迄今为止尝试过的代码
fetch(GLOBAL.LOGIN, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"requestHeader": {
type: "login"
},
"loginData": {
email_id: this.state.email_id,
password: this.state.password
}
})
}).then((response) => {
console.log(response.headers.map.x-auth);
})
我不知道如何访问令牌。请帮助。