试图通过 axios 访问 YouTrack 的 API,但我收到未经授权的错误,而通过 curl 工作的相同参数。
卷曲:
curl -X GET \
'https://<my youtrack url>/api/issues' \
-H 'Authorization: Bearer perm:<my token>' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json'
公牛:
const config = {
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer perm:<my token>'
},
responseType: 'json',
};
axios.get('https://<my youtrack url>/api/issues', {}, config)
.then((response) => {
console.log(response.data);
})
.catch(e => {
console.log('Error: ', e.response.data)
});
curl 正确返回我的可用问题的 JSON,而我的 axios 调用返回错误
{error: "Unauthorized", error_description: ""}
谢谢