Skip to content

Commit 5869c20

Browse files
committed
Update pagination util to support more types of pagination data formats
1 parent 6a66205 commit 5869c20

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

utils/Pagination.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@ const fetchPages = async (url, data = {}, paginationPropsOverride = {}, customSe
4343
const result = await (await Request.get(url, dataWithPaginationParams, customSettings)).json();
4444

4545
fetchedPages.push(...result[paginationProps.DATA]);
46-
page = result[paginationProps.PAGE] + 1;
46+
page = result[paginationProps.PAGE] === null ? null : (result[paginationProps.PAGE] + 1);
4747
count = result[paginationProps.COUNT];
48-
} while ((page - 1) * data[paginationProps.PER_PAGE] < count);
48+
} while (
49+
((page - 1) * data[paginationProps.PER_PAGE] < count) &&
50+
page !== null // Protect from endpoints that drop pagination support
51+
);
4952

5053
return fetchedPages;
5154
};

0 commit comments

Comments
 (0)