-
Notifications
You must be signed in to change notification settings - Fork 3
/
github.js
40 lines (36 loc) · 1.02 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
const axios = require("axios");
const githubAPI = {
License: (license) => {
const licenseURL = `https://api.github.com/licenses/${license}`;
console.log(license);
if (license === "None") {
return;
}
return axios
.get(licenseURL)
.then(function (response) {
const { body } = response.data;
return body;
})
.catch(function (err) {
console.log(err);
});
},
Data: (username) => {
const queryUrl = `https://api.github.com/users/${username}/events/public`;
return axios
.get(queryUrl)
.then(function (res) {
const { avatar_url } = res.data[0].actor;
const { email } = res.data[0].payload.commits[0].author;
return {
avatar_url,
email,
};
})
.catch(function (err) {
console.log(err);
});
}
}
module.exports = githubAPI;