This is how I'm using the method:
github.repos.getStatsContributors({
repo: 'Cloudformation-Webserver',
owner : 'DorrinPk'
}, function (err, res) {
console.log(err, res);
});
The first time I run it for the repo I get null results. The second time I run it I get :
null { data: [ { total: 4, weeks: [Object], author: [Object] } ], meta: { 'x-ratelimit-limit': '5000',
'x-ratelimit-remaining': '4968',
'x-ratelimit-reset': '1499712495',
'x-oauth-scopes': 'admin:org, admin:repo_hook, notifications, repo, user',
'x-github-request-id': 'A05B:0684:271B6:59CB1:5963C4D0',
'x-github-media-type': 'github.v3; format=json',
etag: '"f1ea81d88281adf31e1178d0804f230c"',
status: '200 OK' } }
I know total:4 is the number of my commits on the repo but I only get [Object] back for author and weeks.
am I doing something wrong? I was expecting to get similar results to this.
The first thing you are printing out to the console is the
errobject from the response. In this case the request was successful, so the error is null.The second thing you are writing is the response object. When using the
console.logmethod like that it will not display all levels deep of an object and you must either use the inspector to get a better look or write out the property itself (in your case you could useconsole.log(res.data[0].author))You are getting the correct results, it is just that the
console.logmethod is printing out differently than what you were expecting to see, but it is all there.