2016-02-29 10:45:19 +00:00
|
|
|
'use strict';
|
|
|
|
|
2016-03-02 22:45:23 +00:00
|
|
|
var _ = require('lodash/fp');
|
2016-02-29 10:45:19 +00:00
|
|
|
var request = require('request');
|
|
|
|
|
|
|
|
module.exports = function getUserInfo(username, cb) {
|
|
|
|
request.get({
|
|
|
|
url: 'https://api.github.com/users/' + username,
|
|
|
|
headers: {
|
|
|
|
'User-Agent': 'request'
|
|
|
|
}
|
|
|
|
}, function(error, res) {
|
|
|
|
if (error) {
|
|
|
|
return cb(error);
|
|
|
|
}
|
2016-03-06 18:37:26 +00:00
|
|
|
var body = JSON.parse(res.body);
|
|
|
|
var user = {
|
|
|
|
login: body.login,
|
|
|
|
name: body.name,
|
|
|
|
avatar_url: body.avatar_url,
|
|
|
|
profile: body.blog || body.html_url
|
|
|
|
};
|
|
|
|
return cb(null, user);
|
2016-02-29 10:45:19 +00:00
|
|
|
});
|
|
|
|
}
|