[英]Create Issue in github through api using nodejs and request: response is undefined
[英]Using GitHub API to create new issue
我正在尝试使用 GitHub API 创建一个 GitHub 问题,我发现这个https://github.com/ceceliacreates/APITools这正是我所需要的,但它一直显示我的 GitHub 821030851 未找到
以下是代码:
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);
错误:404 URL 未找到
我正在查看官方 GitHub 网站以了解 API 的用法,但我找不到任何错误。 谁能帮我解决这个问题?
[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
}
}
该代码来自github.com/ceceliacreates/APITools/CreateIssuesFromJSON/CreateIssuesFromJSON.js
。
除了fetch("https://api.github.com/repos/${user}/${repo}/issues")
好像是按照我之前说的header。
您需要仔细检查使用的令牌及其关联的 scope 。
并尝试使用库本身。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.