mirror of
https://github.com/all-contributors/cli.git
synced 2025-01-10 14:06:34 +00:00
c4d04d00ee
* Provide a fallback for null display names. * Check empty strings too.
24 lines
534 B
JavaScript
24 lines
534 B
JavaScript
'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'
|
|
}
|
|
}, 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);
|
|
});
|
|
};
|