Skip to content

Commit

Permalink
fix($api-gitee-v5): get comments count from headers (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorlxy committed Sep 6, 2019
1 parent 394bf42 commit b07d745
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions packages/@vssue/api-gitee-v5/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,20 +296,13 @@ export default class GiteeV5 implements VssueAPI.Instance {
Accept: ['application/vnd.gitee.html+json'],
},
}
const issueOptions: AxiosRequestConfig = { params: {} }
if (accessToken) {
options.params.access_token = accessToken
issueOptions.params.access_token = accessToken
}

// total_count of comments is not available now, so we have to request issue to get the count
const [response, issueResponse] = await Promise.all([
this.$http.get(`repos/${this.owner}/${this.repo}/issues/${issueId}/comments`, options),
this.$http.get(`repos/${this.owner}/${this.repo}/issues/${issueId}`, issueOptions),
])
const response = await this.$http.get(`repos/${this.owner}/${this.repo}/issues/${issueId}/comments`, options)

const count = Number(issueResponse.data.comments)
// const count = Number(response.headers['total_count'])
const count = Number(response.headers['total_count'])

return {
count: count,
Expand Down

0 comments on commit b07d745

Please sign in to comment.