class Github {
constructor() {
this.client_id = '44b38368d3defba969d5';
this.client_secret = '1bd40274a7e6b9baa847935eaba35e2b7c325ec4';
this.repos_count = 5;
this.repos_sort = 'created: asc';
}
async getUser(user) {
const profileResponse = await fetch(`https://api.github.com/users/${user}?client_id=${this.client_id}&client_secret=${this.client_secret}`);
const repoResponse = await fetch(`https://api.github.com/users/${user}/repos?per_page=${this.repos_count}&sort=${this.repos_sort}&client_id=${this.client_id}&client_secret=${this.client_secret}`);
const profile = await profileResponse.json();
const repos = await repoResponse.json();
return {
profile,
repos
}
}
}
请在此说明排序方法ASC的用法。基本上,我还需要对Github存储库进行排序。