-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGithub.js
43 lines (39 loc) · 1.01 KB
/
Github.js
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class Github {
/**
* Author Safnaj on 03/07/2019
* Project Github-User-Finder
**/
constructor() {
this.client_id = "8333fc3680f2476f6df5";
this.client_secret = "233e425ed6e3e58bc61c608c17015266aefd91ad";
this.repos_count = 5;
this.repos_sort = "created : asc";
}
async getUser(user) {
const profileResponse = await fetch(
`https://api.github.com/users/${user}`,
{
headers: {
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}`,
{
headers: {
client_id: this.client_id,
client_secret: this.client_secret,
},
}
);
const profile = await profileResponse.json(); //Storing Profile Response
const repos = await repoResponse.json(); //Storing Repo Response
//returns
return {
profile,
repos,
};
}
}