Skip to content

Commit

Permalink
Fixing pagination limit parsed as NaN as it's null
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrunkat committed Nov 7, 2019
1 parent b9bcc08 commit cdc4905
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ export const parseBody = (body, contentType) => {
* Wrap results from response and parse attributes from apifier headers.
*/
export function wrapArray(response) {
const limit = response.headers['x-apifier-pagination-limit'] || response.headers['x-apify-pagination-limit'];

/**
* @typedef {Object} PaginationList
* @property {Array} items - List of returned objects
Expand All @@ -268,7 +270,7 @@ export function wrapArray(response) {
total: parseInt(response.headers['x-apifier-pagination-total'] || response.headers['x-apify-pagination-total'], 10),
offset: parseInt(response.headers['x-apifier-pagination-offset'] || response.headers['x-apify-pagination-offset'], 10),
count: parseInt(response.headers['x-apifier-pagination-count'] || response.headers['x-apify-pagination-count'], 10),
limit: parseInt(response.headers['x-apifier-pagination-limit'] || response.headers['x-apify-pagination-limit'], 10),
limit: limit ? parseInt(limit, 10) : null, // Limit can be null in a case of dataset items.
};
}

Expand Down

0 comments on commit cdc4905

Please sign in to comment.