node.js - How to connect to gitHub api using nodejs from a secure network? -


i using below code repositories github. when use home network able retrieve list of repositories, if try fetch repo other network gives me error: 'connect econnrefused'. new nodejs, still wondering how go solving issue.

any ideas?

var https = require("https"); var username='xyz'; var options = { host :"api.github.com", path : '/users/'+username+'/repos', method : 'get' }  var request = https.request(options, function(response){ var body = ''; response.on('data',function(chunk){     body+=chunk; }); response.on('end',function(){     var json = json.parse(body);     var repos =[];     json.foreach(function(repo){         repos.push({             name : repo.name,             description : repo.description         });     });     console.log('the repos  '+ json.stringify(repos)); });  }); request.on('error', function(e) { console.error('and error '+e); }); request.end(); 

change options as

var options = {  host:'api.github.com',  path: '/users/' + username+ '/repos',  method: 'get',  headers: {'user-agent':'mozilla/4.0 (compatible; msie 7.0; windows nt 6.0)'}  }; 

Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -