all-contributors-cli/lib/contributors/github.js

25 lines
534 B
JavaScript
Raw Normal View History

'use strict';
var request = require('request');
module.exports = function getUserInfo(username, cb) {
request.get({
url: 'https://api.github.com/users/' + username,
headers: {
'User-Agent': 'request'
}
2016-03-06 23:20:24 +00:00
}, function (error, res) {
if (error) {
return cb(error);
}
var body = JSON.parse(res.body);
var user = {
login: body.login,
name: body.name || username,
avatar_url: body.avatar_url,
profile: body.blog || body.html_url
};
return cb(null, user);
});
2016-03-06 23:20:24 +00:00
};