1

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.

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

I was checking the official GitHub website for the API usage, but I can't find anything wrong. 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
  }
}
riQQ
  • 9,878
  • 7
  • 49
  • 66
Grace
  • 7
  • 1
  • The original has [no slash at the end](https://github.com/ceceliacreates/APITools/blob/e645db5036cd1f76820e86be4ec2c17dde77def1/CreateIssuesFromJSON/CreateIssuesFromJSON.js#L9). – user3840170 Feb 21 '22 at 08:29

1 Answers1

0

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

It seems to follow the header I mentioned before.

You need to double-check the token used, and its associated scope.

And try to use the library itself.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250