我是新手,正在尝试 github API。我尝试了这个示例,它基本上将用户信息记录到控制台。但是,我希望它作为来自正在通过节点运行的服务器的响应返回。下面给出的是代码:
"use strict";
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
// res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
var Client = require("github");
var github = new Client({
debug: true,
version: "3.0.0"
});
github.authenticate({
type: "basic",
username: "user",
password: "password"
});
github.user.get({}, function(err, res) {
console.log("GOT ERR?", err);
console.log("GOT RES?", res);
github.repos.getAll({}, function(err, res) {
console.log("GOT ERR?", err);
console.log("GOT RES?", res);
});
});
怎么做到呢?