Skip to content

Commit

Permalink
Fixing bugs in the Pager
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasmiller committed Apr 21, 2020
1 parent 97e2656 commit 5b86c2f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/recurly/BaseClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class BaseClient {
const jsonContent = (resp.contentType && resp.contentType.includes(JSON_CONTENT_TYPE))

if (resp.status < 200 || resp.status > 299) {
if (jsonContent) {
if (jsonContent && resp.body) {
const errBody = resp.body && JSON.parse(resp.body).error
// If we have a body, we determine the error based on
// the contents of the body
Expand Down
4 changes: 2 additions & 2 deletions lib/recurly/Pager.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Pager {
* @return {Number} The count of resources
*/
async count () {
const empty = await this.client._makeRequest('HEAD', this.path, null, { params: this._consumeParams() })
const empty = await this.client._makeRequest('HEAD', this.path, null, { params: this.params })
return empty.getResponse().recordCount
}

Expand All @@ -51,7 +51,7 @@ class Pager {
async first () {
this.params = this.params || {}
this.params['limit'] = 1
let results = await this.client._makeRequest('GET', this.path, null, { params: this._consumeParams() })
let results = await this.client._makeRequest('GET', this.path, null, { params: this.params })
return results.data && results.data[0]
}

Expand Down

0 comments on commit 5b86c2f

Please sign in to comment.