从node.js创建GitHub repo

时间:2014-04-18 14:46:59

标签: javascript node.js github-api

我在我的节点项目中有这个功能,它应该为特定用户创建一个新的GitHub存储库:

exports.create_repo = function (repo) {
var options = {
    host: "api.github.com",
    path: "/user/repos?access_token=" + repo.accessToken,
    method: "POST",
    json: { name: repo.name },
    headers: { "User-Agent": "github-app" }
};

var request = https.request(options, function(response){
    var body = '';
    response.on("data", function(chunk){ body+=chunk.toString("utf8"); });

    response.on("end", function(){
        var json = JSON.parse(body);
        console.log(json);
    });
});

request.end();
}

每次使用时,回复都是:

{ message: 'Not Found',
documentation_url: 'https://developer.github.com/v3' }

我做错了什么?

0 个答案:

没有答案