搜索 github api 返回不一致的结果
searching github api is returning inconsistent results
我 运行 在快速服务器中使用 axios 进行查询以获取前 3 个 repos,其中 language = javascript:
axios({
headers: {
Accept: 'application/vnd.github.v3+json'
},
method: 'get',
url: 'https://api.github.com/search/repositories',
params: {
q: 'language:JavaScript',
sort: 'stars',
order: 'desc',
per_page: 3
}
})
.then(res => {
console.log(res.data)
})
.catch(err => {
console.log(err)
})
它每次返回 3 个不同的结果。
我做错了什么??
答案在这里:
它与 github 限制任何查询可以 运行 的时间有关。你必须通过添加另一个限定符来帮助它,比如 stars:>1600
我 运行 在快速服务器中使用 axios 进行查询以获取前 3 个 repos,其中 language = javascript:
axios({
headers: {
Accept: 'application/vnd.github.v3+json'
},
method: 'get',
url: 'https://api.github.com/search/repositories',
params: {
q: 'language:JavaScript',
sort: 'stars',
order: 'desc',
per_page: 3
}
})
.then(res => {
console.log(res.data)
})
.catch(err => {
console.log(err)
})
它每次返回 3 个不同的结果。 我做错了什么??
答案在这里:
它与 github 限制任何查询可以 运行 的时间有关。你必须通过添加另一个限定符来帮助它,比如 stars:>1600