forked from alainyog/JavaScript.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub-api.js
More file actions
31 lines (26 loc) · 705 Bytes
/
github-api.js
File metadata and controls
31 lines (26 loc) · 705 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
var request = require('request');
var GithubApi = {
fetchEmail(profile, token, cb) {
var options = {
headers: {
'User-Agent': baseURL,
'Authorization': 'token ' + token
},
json: true,
url: 'https://api.github.com/user/emails'
};
// get emails using oauth token
request(options, function(error, response, body) {
console.log(error);
console.log(response);
console.log(body);
var emails = body.filter(function(email) {
return (email.verified && email.primary);
return email.verified;
});
profile.email = emails[0].email;
cb(profile);
});
}
}
module.exports = GithubApi;