-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub.js
More file actions
34 lines (28 loc) · 957 Bytes
/
github.js
File metadata and controls
34 lines (28 loc) · 957 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
27
28
29
30
31
32
33
34
// Client ID
// 9dfe1781300341027569
// Client Secret
// e6b3590485c1648cf9fea9724f0d4e312cc4a640
// create the Github class
class Github {
constructor() {
this.client_id = "9dfe1781300341027569";
this.client_secret = "e6b3590485c1648cf9fea9724f0d4e312cc4a640";
this.sort = "created: asc";
this.limit = "5";
}
// getting the profile data from github api, async and then the function name:
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.limit}&sort=${this.sort}&client_id=${this.client_id}&client_secret=${this.client_secret}`
);
const profile = await profileResponse.json();
const repos = await repoResponse.json();
return {
profile,
repos,
};
}
}