我想使用JWT
express
方法将axios
令牌发送到POST
服务器。
我尝试过的是:
let data = data
let head = {header: { Token: localStorage.getItem("token") }}
axios
.post("http://localhost:3003/api/v/helllo", data, head)
.then((result) => {
console.table(result);
})
.catch((err) => {
console.error(err);
});
答案 0 :(得分:0)
通常,在使用JWT
-Authorization
标头时。另外请注意,应使用header
-headers
字段代替:
let head = {
headers: {
Authorization: 'Bearer ' + localStorage.getItem("token")
}
};
请注意,将令牌存储在本地存储中并不安全。