/ bot / github.js
github.js
 1  'use strict'
 2  
 3  const octokit = require('@octokit/rest')()
 4  
 5  // Returns all the bounty labelNames of a given issue (Github API v3)
 6  async function getLabels (req) {
 7    const labelsPayload = await octokit.issues.getIssueLabels({
 8      owner: req.body.repository.owner.login,
 9      repo: req.body.repository.name,
10      number: req.body.issue.number
11    })
12  
13    return labelsPayload.data.map(labelObj => labelObj.name)
14  }
15  
16  module.exports = {
17    getLabels: getLabels
18  }