Art*_*hur 6 rest youtrack youtrack-api axios
试图通过axios尝试使用YouTrack的API,但我收到了未经授权的错误,同时通过卷曲工作获得相同的参数.
卷曲:
curl -X GET \
'https://<my youtrack url>/api/issues' \
-H 'Authorization: Bearer perm:<my token>' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json'
Run Code Online (Sandbox Code Playgroud)
爱可信:
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)
});
Run Code Online (Sandbox Code Playgroud)
curl正确返回我可用问题的JSON,而我的axios调用返回错误
{error: "Unauthorized", error_description: ""}
Run Code Online (Sandbox Code Playgroud)
谢谢
发送配置作为第二个参数,因为GET请求不需要正文
axios.get('https://<my youtrack url>/api/issues', config)
.then((response) => {
console.log(response.data);
})
.catch(e => {
console.log('Error: ', e.response.data)
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
277 次 |
最近记录: |