-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub.js
More file actions
26 lines (22 loc) · 860 Bytes
/
github.js
File metadata and controls
26 lines (22 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class Github {
constructor(){
// took it from adress: https://github.com/settings/applications/980750 to make >100 request per hour
this.client_id = 'f8fd12b916c9054ea846';
this.client_secret = '5f47c4afe9b176caf5f201d65aab55da4468ad59';
this.repos_count = 6;
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 reposResponse = 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 reposResponse.json();
return {
profile,
repos
}
}
}