外层fetch获取到了token,里面的fetch报错,并且请求头里面没有传输的Authorization。
let token;
fetch('http://192.168.188.128:9080/user/login', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
username: 'zhangjh',
password: 123,
}),
})
.then(res => res.json())
.then((json) => {
token = json.token;
fetch('http://192.168.188.128:9080/user/userid', {
method: 'post',
mode: 'no-cors',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
Authorization: token,
},
})
.then(res => res.json())
.then((data) => {
console.log(data);
})
.catch(err => console.log(err));
})
.catch(err => console.log(err));
胡子哥哥
相关分类