export const login = user => {
return fetch("users/login", {
method: 'POST',
body: JSON.stringify({
email: user.email,
password: user.password
}),
headers : {'Content-type':'application/json','Authorization':'Bearer'+user.token}
}).then(response =>{
console.log("hjhsfdgsdhgfsdggd"+response.formData.token)
// On below line it thorws an exception
window.localStorage.setItem('usertoken',response.formData.token)
return response.formData.token
}).catch(err =>{
console.log(err);
})
}
突出显示的代码将引发错误:
语法错误:调试时意外导出令牌
并且在本地存储中查看时,密钥为未定义
我正在使用jwt进行令牌身份验证