[英]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.