使用Meteor访问github仓库中所有文件的名称

正如标题所说,我正在写一个meteor的Web应用程序,并试图访问github回购中的所有文件的名称。 我有一个Node github api包装器(它包装的实际api位于https://github.com/mikedeboer/node-github ),我能够成功地做一些其他的github api调用(即github。 repos.getAll和gethub.user.getFollowingFromUser)。 但是,出于某种原因,当我尝试使用github.repos.getContent时,无论我作为用户名还是回购传入,都会收到404错误。

所以这个工作:

github.user.getFollowingFromUser( { user: "ndhoule" }, function(err, res) { console.log(JSON.stringify(res)); }); 

但是这不是:

  github.repos.getContent( { user: "ndhoule", repo: "meteor-github-api" }, function(err, res){console.log(JSON.stringify(res)) }); 

这是它产生的错误:

 I20141029-13:46:01.875(-5)? [error] { [Error: {"message":"Not Found","documentation_url":"https://developer.github.com/v3"}] I20141029-13:46:01.876(-5)? [error] message: '{"message":"Not Found","documentation_url":"https://developer.github.com/v3"}', I20141029-13:46:01.877(-5)? [error] code: 404 } null ndhoule I20141029-13:46:01.877(-5)? undefined 

这种情况发生,无论我插入那里的用户名,所以我假设我以某种方式错误地使用getContent方法。 如果任何人都可以弄清楚我的错误是什么(或者可能提出了一个不同的方式来从meteor的回购文件中获取文件名),我将不胜感激这个帮助。

编辑:我试过指定一个path(即使这是一个可选的参数),我得到了一个稍微不同的结果。

修改后的代码:

 github.repos.getContent( { user: "ndhoule", repo: "meteor-github-api" path: "./" }, function(err, res){console.log(JSON.stringify(res)) }); 

现在我在控制台中只有这个输出:

 {"meta":{"x-ratelimit-limit":"60","x-ratelimit-remaining":"59"}} 

我已经试过你的代码,我正在获取文件内容的回购

在这里输入图像描述

从这个问题https://github.com/mikedeboer/node-github/issues/137我已经设置了function的path

我的代码

 client.js Meteor.call("repocontent",uname,repoName,function(e,r){ console.log(r); }); 

服务器方法中的server.js

  'repocontent':function(uname,repoName){ var reposcontent=Async.runSync(function(done){ github.repos.getContent({user:uname,repo:repoName,path: ""},function(err,data){ done(null,data) ; }); }); return reposcontent; },