1

我有这个功能:

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

我尝试了其他几种组合,但没有运气。除了在此处输入链接描述外,我也找不到任何在线代码示例

有人可以告诉我这应该如何编码吗?

4

2 回答 2

1

您收到错误"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上的文档

于 2018-09-14T23:00:16.593 回答
0

我已经更改了过滤器,所以现在在标签上包含一个过滤器:

let response = await method({
    q: "repo:" + repoOrg + "/" + repoName + " is:issue" + " label:label_name" + " state:open",
    per_page: 100
  });
于 2018-09-13T20:21:52.353 回答