From 00404f6d456bf59a197d729c9377f6dc8bfbde08 Mon Sep 17 00:00:00 2001 From: demirgazetic Date: Thu, 1 Aug 2024 14:05:29 +0200 Subject: [PATCH] Refactor getAll method to use a single page variable and update pagination logic - Updated the pagination logic to use a single `page` variable for both the initial response and the for loop. - Changed the calculation of `lastPage` by dividing the total number by 100 instead of 25 to optimize the page count. --- lib/src/sync.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/sync.js b/lib/src/sync.js index ad6b75510..078e0ab16 100644 --- a/lib/src/sync.js +++ b/lib/src/sync.js @@ -89,11 +89,11 @@ module.exports = { initialResponse.data[type].constructor === Object ? Object.values(initialResponse.data[type]) : initialResponse.data[type]; - let lastPage = Math.ceil(initialResponse.total / 25); + let lastPage = Math.ceil(initialResponse.total / 100); const fetchPromises = []; - for (let p = 2; p <= lastPage; p++) { - fetchPromises.push(this.getPage(type, p, options)); + for (page = 2; page <= lastPage; page++) { + fetchPromises.push(this.getPage(type, page, options)); } const pageResponses = await Promise.all(fetchPromises); @@ -116,5 +116,5 @@ module.exports = { }); return allItems; - }, + } };