rozod 3.1.3 → 3.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +5 -5
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -68,8 +68,8 @@ function prepareRequestBody(method, requestFormat, body) {
|
|
|
68
68
|
return body;
|
|
69
69
|
}
|
|
70
70
|
async function handleRetryFetch(url, requestOptions, retries, retryDelay, body, method) {
|
|
71
|
-
let response;
|
|
72
|
-
while (
|
|
71
|
+
let response = undefined;
|
|
72
|
+
while (response === undefined) {
|
|
73
73
|
try {
|
|
74
74
|
response = await fetch(url, {
|
|
75
75
|
method,
|
|
@@ -203,9 +203,9 @@ exports.fetchApiSplit = fetchApiSplit;
|
|
|
203
203
|
*/
|
|
204
204
|
async function fetchApiPages(endpoint, initialParams, requestOptions, limit = 1000) {
|
|
205
205
|
const allResults = [];
|
|
206
|
-
for await (const { nextPageCursor, ...response } of fetchApiPagesGenerator(endpoint, initialParams, requestOptions)) {
|
|
206
|
+
for await (const { nextPageCursor, ...response } of fetchApiPagesGenerator(endpoint, initialParams, requestOptions, limit)) {
|
|
207
207
|
allResults.push(response);
|
|
208
|
-
if (allResults.length >= limit || nextPageCursor === null) {
|
|
208
|
+
if (allResults.length >= limit || nextPageCursor === null || nextPageCursor === undefined) {
|
|
209
209
|
break;
|
|
210
210
|
}
|
|
211
211
|
}
|
|
@@ -236,7 +236,7 @@ async function* fetchApiPagesGenerator(endpoint, initialParams, requestOptions,
|
|
|
236
236
|
const paramsWithCursor = { ...initialParams, cursor };
|
|
237
237
|
const response = await fetchApi(endpoint, paramsWithCursor, requestOptions);
|
|
238
238
|
yield response;
|
|
239
|
-
if (response.nextPageCursor === null || limit-- <= 0) {
|
|
239
|
+
if (response.nextPageCursor === null || response.nextPageCursor === undefined || limit-- <= 0) {
|
|
240
240
|
break;
|
|
241
241
|
}
|
|
242
242
|
cursor = response.nextPageCursor;
|