如何将Express JS应用程序连接到github API [英] How to connect an express JS app to github API

查看:57
本文介绍了如何将Express JS应用程序连接到github API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近第一次开始使用expressJS.我在将其连接到github API时遇到麻烦,因此我可以运行命令以在给定的存储库上查找注释和类似内容.

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.

任何帮助都会很棒!

谢谢!

我尝试使用: https://github.com/mikedeboer/node-github 但我不确定如何将此API与expressJS应用集成

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));
});

推荐答案

您可以使用包装Github API的库.例如,node-github(覆盖100%).

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

这篇关于如何将Express JS应用程序连接到github API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆