diff --git a/packages/nodes-base/nodes/Lemlist/GenericFunctions.ts b/packages/nodes-base/nodes/Lemlist/GenericFunctions.ts index 70e6e5c465..5257c0234e 100644 --- a/packages/nodes-base/nodes/Lemlist/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Lemlist/GenericFunctions.ts @@ -51,11 +51,11 @@ export async function lemlistApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, method: string, endpoint: string, + qs: IDataObject = {}, ) { const returnData: IDataObject[] = []; let responseData; - const qs: IDataObject = {}; qs.limit = 100; qs.offset = 0; diff --git a/packages/nodes-base/nodes/Lemlist/Lemlist.node.ts b/packages/nodes-base/nodes/Lemlist/Lemlist.node.ts index 3343d185aa..e1b3faf0de 100644 --- a/packages/nodes-base/nodes/Lemlist/Lemlist.node.ts +++ b/packages/nodes-base/nodes/Lemlist/Lemlist.node.ts @@ -123,7 +123,7 @@ export class Lemlist implements INodeType { // https://developer.lemlist.com/#activities - const returnAll = this.getNodeParameter('returnAll', 0); + const returnAll = this.getNodeParameter('returnAll', i); const qs = {} as IDataObject; const filters = this.getNodeParameter('filters', i); @@ -132,11 +132,11 @@ export class Lemlist implements INodeType { Object.assign(qs, filters); } - responseData = await lemlistApiRequest.call(this, 'GET', '/activities', {}, qs); - - if (!returnAll) { - const limit = this.getNodeParameter('limit', 0); - responseData = responseData.slice(0, limit); + if (returnAll) { + responseData = await lemlistApiRequestAllItems.call(this, 'GET', '/activities', qs); + } else { + qs.limit = this.getNodeParameter('limit', i); + responseData = await lemlistApiRequest.call(this, 'GET', '/activities', {}, qs); } } } else if (resource === 'campaign') { @@ -151,13 +151,15 @@ export class Lemlist implements INodeType { // https://developer.lemlist.com/#list-all-campaigns - responseData = await lemlistApiRequest.call(this, 'GET', '/campaigns'); - const returnAll = this.getNodeParameter('returnAll', i); - if (!returnAll) { - const limit = this.getNodeParameter('limit', i); - responseData = responseData.slice(0, limit); + if (returnAll) { + responseData = await lemlistApiRequestAllItems.call(this, 'GET', '/campaigns', {}); + } else { + const qs = { + limit: this.getNodeParameter('limit', i), + }; + responseData = await lemlistApiRequest.call(this, 'GET', '/campaigns', {}, qs); } } } else if (resource === 'lead') { @@ -277,7 +279,7 @@ export class Lemlist implements INodeType { const returnAll = this.getNodeParameter('returnAll', i); if (returnAll) { - responseData = await lemlistApiRequestAllItems.call(this, 'GET', '/unsubscribes'); + responseData = await lemlistApiRequestAllItems.call(this, 'GET', '/unsubscribes', {}); } else { const qs = { limit: this.getNodeParameter('limit', i),