I need to get from this answer, only the error number. If it is 404, 403, or some other. This is done at NodeJS, does anyone have any idea how I can do it? I leave the answer.
GotError: GET https://api.github.com/repos/org/repo/contents/package.json response code is 403 (Forbidden)
at /Users/santiago/Documents/license/node_modules/got/index.js:175:12
at BufferStream.<anonymous> (/Users//Documents/license/node_modules/read-all-stream/index.js:64:3)
at emitNone (events.js:91:20)
at BufferStream.emit (events.js:185:7)
at finishMaybe (/Users//Documents/license/node_modules/readable-stream/lib/_stream_writable.js:513:14)
at endWritable (/Users//Documents/license/node_modules/readable-stream/lib/_stream_writable.js:523:3)
at BufferStream.Writable.end (/Users//Documents/license/node_modules/readable-stream/lib/_stream_writable.js:493:41)
at Unzip.onend (_stream_readable.js:511:10)
at Unzip.g (events.js:291:16)
at emitNone (events.js:91:20) nested: null, code: 403 }
getFromGithub: function(allRepos, callback){
var self = this;
var apiRequest = api('/repos/' + self.settings.org + '/' + self.repo + '/contents/package.json', {
token: self.settings.gitToken
});
apiRequest.on('data', function(response) {
self.reposParsed = JSON.stringify(allRepos);
var packageJSON = new PackageJSON(self.settings, self.reposParsed);
packageJSON.parseFromString(response.content, function(){
self.getLicenseTree(packageJSON, function(err){
if(err)
return callback(err, null);
self.licenses = packageJSON.list;
callback(null, self.licenses);
});
});
});
apiRequest.on('error', function(err) {
console.log(err);
callback(err, null);
});
},