[英]Auth0 axios.post with token Internal Server Error 500
我正在尝试使用来自 Auth0 的令牌 header 通过 axios.post 发布。 我收到以下错误
代码
const [AccessToken, setAccessToken] = useState(null);
useEffect(() => {
(async () => {
const token = await getAccessTokenSilently({
audience: 'api.paintit',
scope: 'read:posts',
});
setAccessToken(token);
})();
}, []);
axios.post(
url,
{data:{
data
}
},
{
headers: {
'Authorization': `Bearer ${AccessToken}`
}
}
).then((response) => {
console.log(response);
})
.catch((error) => {
console.log(error.response);
});
我需要将 header 添加到 axios 以供登录用户使用。 这适用于获取请求和发布请求,我收到了该错误。 请帮助我将非常感激。
axios.post(
url,
data,
{
headers: {
'Authorization': `Bearer ${AccessToken}`
}
}
).then((response) => {
console.log(response);
})
.catch((error) => {
console.log(error.response);
});
我是添加数据错误
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.