fix(monicaCrm Node): fix pagination when using return all

This commit is contained in:
Jonathan Bennetts 2022-09-02 15:43:14 +01:00 committed by GitHub
parent 49c85a1df8
commit 82827d0a12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -67,6 +67,8 @@ export async function monicaCrmApiRequestAllItems(
const limit = this.getNodeParameter('limit', 0, 0) as number; const limit = this.getNodeParameter('limit', 0, 0) as number;
let totalItems = 0; let totalItems = 0;
qs.page = 1;
qs.limit = 100;
let responseData; let responseData;
const returnData: IDataObject[] = []; const returnData: IDataObject[] = [];
@ -78,7 +80,7 @@ export async function monicaCrmApiRequestAllItems(
if (!forLoader && !returnAll && returnData.length > limit) { if (!forLoader && !returnAll && returnData.length > limit) {
return returnData.slice(0, limit); return returnData.slice(0, limit);
} }
qs.page++;
totalItems = responseData.meta.total; totalItems = responseData.meta.total;
} while (totalItems > returnData.length); } while (totalItems > returnData.length);