使用nodejs和request:response通过api在github中创建Issue

Create Issue in github through api using nodejs and request: response is undefined

本文关键字:github 创建 Issue api 通过 nodejs request response 使用      更新时间:2023-09-26

我读过这个问题:向Github API发出Post请求以创建问题不起作用,但我正在寻找使用请求模块的支持。我已经阅读了github文档,但我很难将它们的curl示例翻译成javascript。

这是slack/github与slash命令集成的更大尝试的一部分。现在我只是想向github提交一个通用请求。当我记录响应的正文时,它是"未定义的"。

我宁愿不使用github包装器,因为我想了解我在做什么,以及为什么它不能更好地工作。

非常感谢对这个角落的任何帮助。

编辑:根据评论中的建议进行了更改错误为ECONNREFUSED当我试图记录响应状态时,我遇到了一个错误,因为响应是未定义的。

    request({
    "url":"http://api.github.com/repos/user/repo/issues",
    "method":"POST",
    "headers": {"Authorization": "auth token"},
    "body": JSON.stringify({ title: "Found a bug", body: "I'm having a problem  this." })
    }, function(err, response, body) {
        console.log(body);
        if (err) console.log(err);
    });
  });

评论中列出的其他问题(感谢大家)。在我的URL中,我有http而不是https。

DOH