리포지토리 ID 배열에 모든 리포지토리를 포함시킬 수있는 방법이 있습니까? 이 같은모든 github 리포지토리를 리포지토리 배열에 포함시킵니다. Id
뭔가 ...
const githubRepoIds = [ 1,2,3 ];
fetch(`/search/repositories/q=${githubRepoIds.join(',')} in:id`)
리포지토리 ID 배열에 모든 리포지토리를 포함시킬 수있는 방법이 있습니까? 이 같은모든 github 리포지토리를 리포지토리 배열에 포함시킵니다. Id
뭔가 ...
const githubRepoIds = [ 1,2,3 ];
fetch(`/search/repositories/q=${githubRepoIds.join(',')} in:id`)
저장소 ID 당 1 요청을하는 개념 증명이 있습니다 (rate limiting 참조).
function getRepositories(ids) {
var promises = ids.map(id => getRepository(id).catch(() => {}));
return Promise.all(promises).then(repos => repos.filter(repo => repo !== undefined));
function getRepository(id) {
return new Promise((resolve, reject) => {
const url = "https://api.github.com/repositories/" + id;
const xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.onreadystatechange =() => {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
resolve(JSON.parse(xhr.response));
} else {
reject();
}
}
};
xhr.send();
});
}
}
사용법 :
const githubRepoIds = [ 1,2,3 ];
getRepositories(githubRepoIds).then(repos => console.log(repos));
은 내가 in
예선 당신은 이름, 설명, 추가 정보 및 이들의 조합을 리포지토리 검색을 제한 할 수 않습니다 생각합니다. 참조하십시오 : https://help.github.com/articles/searching-repositories/#scope-the-search-fields