【问题标题】:How to Return Github Issues from Private Repository (Node.js)如何从私有存储库(Node.js)返回 Github 问题
【发布时间】:2019-02-04 09:51:12
【问题描述】:

我正在尝试使用 Node.js 从私人仓库返回 Github 问题列表。我能够返回一个 repos 列表,但我正在努力返回问题。

您似乎可以根据https://octokit.github.io/octokit.rb/Octokit/Client/Issues.html 此处的文档列出list_issues 函数的问题。但是,在尝试访问该功能时出现错误。

const octokit = require('@octokit/rest')()

octokit.authenticate({
  type: 'basic',
  username: 'username',
  password: 'password'
})

octokit.repos.getForOrg({
  org: 'name_of_organization',
  type: 'private'
}).then(({data, headers, status}) => {
  console.log(data) // returns list of repos as JSON
})

octokit.list_issues("name_of_org/name_of_repo")
  .then(({data, headers, status}) => {
  console.log(data) // error: octokit.list_issues in not a function
})

如何从 Github 以 JSON 格式返回私有问题列表?

【问题讨论】:

标签: json node.js github octokit


【解决方案1】:

基于文档:https://octokit.github.io/rest.js/#api-Search-issues

使用相同的身份验证代码块时,示例请求可能如下所示:

octokit.issues.getAll({
  filter: 'all',
  state: 'open',
  labels: '',
  sort: 'updated',
  direction: 'desc',
  since: '2018-07-01T00:00:00Z',
  per_page: '100',
  page: '1'})
  .then(result => {
    console.log(result)
  })
  .catch(err => {
    console.log(err)
  })

【讨论】:

    猜你喜欢
    • 2013-03-23
    • 2018-11-27
    • 1970-01-01
    • 1970-01-01
    • 2021-01-18
    • 1970-01-01
    • 1970-01-01
    • 2014-05-19
    • 1970-01-01
    相关资源
    最近更新 更多