无法授权 Axios post 请求 Raindrop API
Can't have Authorized Axios post request to Raindrop API
我正在尝试为我的一个雨滴构建一个简单的获取应用程序 collection 并将其显示在项目中。
我正在使用“测试令牌”,所以我现在不必制作所有授权内容。
所有信息(access_token、collection_id)显示良好。
useEffect(() => {
if (accessToken !== null) {
const headers = {
Authorization: `Bearer ${accessToken}`
};
axios.post(
`https://api.raindrop.io/rest/v1/collection/${COLLECTION_ID}`,
{ headers: headers }
).then(console.log).catch(console.log);
}
},[])
我正在注入的 headers 显示在 https
的 Request Payload 中
但是响应只是显示未授权...
有人试过这样做并且可以帮助我吗?
谢谢!
根据axios post请求,第二个参数是body,第三个是headers。
将您的请求更改为,
axios.post(
`https://api.raindrop.io/rest/v1/collection/${COLLECTION_ID}`,
{}, // request body, since post request.
{ headers: headers }
).then(console.log).catch(console.log);
我正在尝试为我的一个雨滴构建一个简单的获取应用程序 collection 并将其显示在项目中。
我正在使用“测试令牌”,所以我现在不必制作所有授权内容。
所有信息(access_token、collection_id)显示良好。
useEffect(() => {
if (accessToken !== null) {
const headers = {
Authorization: `Bearer ${accessToken}`
};
axios.post(
`https://api.raindrop.io/rest/v1/collection/${COLLECTION_ID}`,
{ headers: headers }
).then(console.log).catch(console.log);
}
},[])
我正在注入的 headers 显示在 https
的 Request Payload 中但是响应只是显示未授权...
有人试过这样做并且可以帮助我吗?
谢谢!
根据axios post请求,第二个参数是body,第三个是headers。
将您的请求更改为,
axios.post(
`https://api.raindrop.io/rest/v1/collection/${COLLECTION_ID}`,
{}, // request body, since post request.
{ headers: headers }
).then(console.log).catch(console.log);