Axios 不起作用:
axios
.get("http://localhost:8080/user", {
headers: {
Authorization: "Bearer " + props.token,
},
})
.then((result) => {
console.log("user: " + result);
})
.catch((err) => {
console.log(err);
});
当我使用 fetch() 时,这个工作正常
fetch("http://localhost:8080/user", {
headers: {
Authorization: "Bearer " + props.token,
},
})
.then((res) => {
return res.json();
})
.then((resData) => {
console.log("u ", resData);
});