-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub.js
More file actions
21 lines (18 loc) · 716 Bytes
/
github.js
File metadata and controls
21 lines (18 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class Github{
constructor(){
this.id = config.id;
this.secret = config.secret;
this.repos_count = 5;
this.sort = 'created:asc';
}
async getUser(user){
const profileResponse = await fetch(`https://api.github.com/users/${user}?client_id=${this.id}&client_secret=${this.secret}`)
const reposResponse = await fetch(`https://api.github.com/users/${user}/repos?per_page=${this.repos_count}&sort=${this.sort}&client_id=${this.id}&client_secret=${this.secret}`)
const profile = await profileResponse.json();
const repos = await reposResponse.json();
return {
profile,
repos
}
}
}