| 194 | }) |
| 195 | } |
| 196 | getIssueById () { |
| 197 | const { owner, repo, number, clientID, clientSecret } = this.options |
| 198 | const getUrl = `/repos/${owner}/${repo}/issues/${number}` |
| 199 | |
| 200 | return new Promise((resolve, reject) => { |
| 201 | axiosGithub.get(getUrl, { |
| 202 | auth: { |
| 203 | username: clientID, |
| 204 | password: clientSecret |
| 205 | }, |
| 206 | params: { |
| 207 | t: Date.now() |
| 208 | } |
| 209 | }) |
| 210 | .then(res => { |
| 211 | let issue = null |
| 212 | |
| 213 | if (res && res.data && res.data.number === number) { |
| 214 | issue = res.data |
| 215 | |
| 216 | this.setState({ issue, isNoInit: false }) |
| 217 | } |
| 218 | resolve(issue) |
| 219 | }) |
| 220 | .catch(err => { |
| 221 | // When the status code is 404, promise will be resolved with null |
| 222 | if (err.response.status === 404) resolve(null) |
| 223 | reject(err) |
| 224 | }) |
| 225 | }) |
| 226 | } |
| 227 | getIssueByLabels () { |
| 228 | const { owner, repo, id, labels, clientID, clientSecret } = this.options |
| 229 | |