我有这个功能:
async function paginate(method) {
let response = await method({
q: "repo:" + repoOrg + "/" + repoName + " is:issue",
per_page: 100
});
data = response.data.items;
var count = 0;
while (octokit.hasNextPage(response)) {
count++;
console.log(`request n°${count}`);
response = await octokit.getNextPage(response);
data = data.concat(response.data.items);
}
return data;
}
paginate(octokit.search.issues)
.then(data => {
callback(data);
})
.catch(error => {
console.log(error);
});
}
我希望不运行
octokit.search.issues
,而是运行octokit.issues.getLabel
。我尝试更改:
let response = await method({
q: "repo:" + repoOrg + "/" + repoName + " is:issue",
per_page: 100
});
至:
let response = await octokit.issues.getLabel("owner", "repo", "label_name");
但是我得到了这个错误:
TypeError: callback.bind is not a function
。我尝试了其他几种组合,但是没有运气。除了enter link description here之外,我也找不到在线任何代码示例
有人可以告诉我该如何编码吗?
最佳答案
您收到错误"TypeError: callback.bind is not a function"
,因为您在此处传递了多个参数
octokit.issues.getLabel("owner", "repo", "label_name")
Octokit期望第二个参数是一个回调,因此会出现错误。你想要的是这个
octokit.issues.getLabel({
owner: 'owner',
repo: 'repo',
label_name: 'label_name'
})
请参阅http://octokit.github.io/rest.js/#api-Issues-getLabel上的文档