sac Dahal sac Dahal - 26 days ago 4x
Javascript Question

Accessing github repository using nodejs

I wanted to access github repositories using github api in node.`

var https = require("https");
var userName='sacdh22';
var options = {
host :"",
path: "/users/" +userName+ "/repos",
method : 'GET',
headers: {'User-Agent':'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)'}

var request = https.request(options, function(response){
var body = '';
var json = JSON.parse(body);
var repos =[];
// repos.push({
// name :,
// description : repo.description
// });
console.log('the repos are '+ JSON.stringify(repos));

request.on('error', function(e) {
console.error('and the error is '+e);

When i console.log(body) I get the following output.

{"message":"Not Found","documentation_url":""}
{ message: 'Not Found',
documentation_url: '' }

Can any one tell me what is going wrong here, my guess is that the path is not set properly, so how can I set it?


sacdh22 is not a username on Github. When you try to access a list of their repositories, Github gives you a Not Found error. Change the username to a real one and you will get very different results.