【发布时间】:2013-06-06 01:59:48
【问题描述】:
所以,我正在尝试向 github 发出 HTTP 请求,以返回特定 github 存储库中所有问题的列表。我在下面的代码中使用了 coffeescript,但对于任何 JS 开发人员来说,它应该是相当不言自明的。我的困惑是,如果我在浏览器中输入“https://api.github.com/repos/username/repo-name/issues”,我可以检索到我正在寻找的所有信息。当我尝试使用request node library 通过我的应用程序发出请求时,我收到一条错误消息,提示“缺少或无效的用户代理字符串”。如果您知道如何正确构建 URL 以实际从 github API 检索信息,请告诉我。
githubUrl = "https://api.github.com/repos/#{username}/#{repoName}/issues?state=open"
request githubUrl, (error, response, body) ->
console.log body
【问题讨论】:
标签: javascript node.js api github coffeescript