How to connect an express JS app to github API

有些话、适合烂在心里 提交于 2020-01-06 02:20:08

问题


I recently started using expressJS for the first time. I am having trouble connecting it to the github API so I can run commands to find comments and things like that on a given repo.

Any help would be awesome!

Thanks!

EDIT:

I have tried using: https://github.com/mikedeboer/node-github but I am not sure how to integrate this API with expressJS app

Here is an example of what I have so far that is not working correctly:

var GitHubApi = require("github");

var github = new GitHubApi({
    // required
    version: "3.0.0",
    // optional
    debug: true,
    protocol: "https",
    host: "github.com",
    pathPrefix: "/joyent/node", // for some GHEs
    timeout: 5000
});
github.gitdata.getCommit({
    // optional:
    // headers: {
    //     "cookie": "blahblah"
    // },
    user: "bnoordhuis",
    repo: "/commit",
    sha: "c30cc4e3a5ead3ca5b48e8eec445740775888ed8"
}, function(err, res) {
    console.log(JSON.stringify(res));
});

回答1:


You can use a library that wraps the Github API. For example, node-github (100% covered).

  • Installation: npm install github
  • Documentation: https://github.com/mikedeboer/node-github


来源:https://stackoverflow.com/questions/22489818/how-to-connect-an-express-js-app-to-github-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!