简体   繁体   English

使用 GitHub API 创建新问题

[英]Using GitHub API to create new issue

I'm trying to create a GitHub issue using the GitHub API, and I found this https://github.com/ceceliacreates/APITools which is exactly what I need, but it keeps showing me my GitHub API was not found.我正在尝试使用 GitHub API 创建一个 GitHub 问题,我发现这个https://github.com/ceceliacreates/APITools这正是我所需要的,但它一直显示我的 GitHub 821030851 未找到

Following is the code:以下是代码:

createIssuesFromJSON = function(file) {
    file.forEach(issue => {
        fetch(`https://api.github.com/repos/${user}/${repo}/issues/`, {
            method: 'POST',
            body:    JSON.stringify(issue),
            headers: {'Content-Type': 'application/json', 'Authorization': `${process.env.TOKEN}`}
        })
        .then((res)=>{
            console.log(res);
            return res.json();
        })
        .then(json => {
            
        })
    })
}

createIssuesFromJSON(file);

error: 404 URL not found错误:404 URL 未找到

I was checking the official GitHub website for the API usage, but I can't find anything wrong.我正在查看官方 GitHub 网站以了解 API 的用法,但我找不到任何错误。 Can anyone help me with the situation?谁能帮我解决这个问题?

[Symbol(Response internals)]: {
    url: 'https://api.github.com/repos/{my github}/{my repo}/issues/',
    status: 404,
    statusText: 'Not Found',
    headers: Headers { [Symbol(map)]: [Object: null prototype] },
    counter: 0
  }
}

That code is from github.com/ceceliacreates/APITools/CreateIssuesFromJSON/CreateIssuesFromJSON.js .该代码来自github.com/ceceliacreates/APITools/CreateIssuesFromJSON/CreateIssuesFromJSON.js
Except with fetch("https://api.github.com/repos/${user}/${repo}/issues")除了fetch("https://api.github.com/repos/${user}/${repo}/issues")

It seems to follow the header I mentioned before .好像是按照我之前说的header。

You need to double-check the token used, and its associated scope .您需要仔细检查使用的令牌及其关联的 scope

And try to use the library itself.并尝试使用库本身。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM