【发布时间】:2021-10-21 17:07:30
【问题描述】:
我在 Meteor 中使用 github API 但无法解决这个问题:
此代码尝试获取某个 repo 的总流量。
HTTP.call( 'GET', 'https://api.github.com/repos/hackmdio/hackmd/traffic/views',
{
headers:
{
'Content-Type':'application/json',
"Accept":"application/vnd.github.v3+json",
"User-Agent": "whales"
},
},
function( error, response ) {
if ( error ) {
console.log('---------------------------error occurred-----------------------------------')
console.log('---------------------------error occurred-----------------------------------')
console.log( error );
} else {
console.log('--------------------------data got it!!-------------------------------------')
console.log('--------------------------data got it!!-------------------------------------')
console.log(response);
}
});
错误:
{
"message": "If you would like to help us test the Repo Traffic API during its preview period, you must specify a custom media type in the 'Accept' header. Please see the docs for full details.",
"documentation_url": "https://developer.github.com/v3"
}
我搜索了类似的问题并添加了“Content-Type”和“Accept”,但它仍然无法正常工作。
然后我尝试在 Postman 和终端中使用相同的标题执行此操作,但此错误一直在发生。
非常感谢。
【问题讨论】:
标签: api http meteor github github-api