{"size": 1031, "ext": "js", "max_stars_repo_path": "dia#1/github_user.js", "max_stars_repo_name": "mensonones/desafio", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "dia#1/github_user.js", "max_issues_repo_name": "mensonones/desafio", "max_issues_repo_issues_event_min_datetime": "2017-04-02T16:32:50.000Z", "max_issues_repo_issues_event_max_datetime": "2017-04-02T21:17:36.000Z", "max_forks_repo_path": "dia#1/github_user.js", "max_forks_repo_name": "mensonones/desafio", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 21.0408163265, "max_line_length": 76, "alphanum_fraction": 0.5499515034}
/**
 * Created by emerson on 02/04/17.
 *
 * Uso da biblioteca http/https do Node.js
 *
 * Consumir API do Github
 */

var https = require('https');

var userName = 'mensonones';

var options = {

    host :"api.github.com",
    path : '/users/'+userName,
    method : 'GET',
    headers: {'user-agent': 'node.js'} //essa linha evita erro de requisição
};

var request = https.request(options, function (res) {

   var body = '';

   console.log('Response: ' + res.statusCode);
   console.log('---------------------------');

   res.on('data', function(chunk) {
        body+=chunk;
    });

   res.on('end', function () {

      var json = JSON.parse(body);

      console.log("Nome: " + json.name);
      console.log("Companhia: " + json.company);
      console.log("Número de seguidores: " + json.followers);
      console.log("Número de Respositórios: " + json.public_repos);
      console.log('---------------------------');

   });

    res.on('error', function(e) {
        console.error('o error é '+e);
    });

}).end();
