-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub.js
More file actions
58 lines (49 loc) · 1.81 KB
/
Copy pathgithub.js
File metadata and controls
58 lines (49 loc) · 1.81 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// class Github {
// constructor() {
// this.client_id = "d9308aacf8b204d361fd";
// this.client_secret = "84969aeef73956f4ec9e8716d1840532802bb81b";
// 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 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: profile,
// repos,
// };
// }
// }
class Github {
constructor() {
this.client_id = "d9308aacf8b204d361fd";
this.client_secret = "84969aeef73956f4ec9e8716d1840532802bb81b";
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,
};
}
}