Skip to content

Commit

Permalink
Fix pagination issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Joffcom committed Jul 25, 2023
1 parent eeb49e9 commit ec87777
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions packages/nodes-base/nodes/Lemlist/Lemlist.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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');
} else {
qs.limit = this.getNodeParameter('limit', i);
responseData = await lemlistApiRequest.call(this, 'GET', '/activities', {}, qs);
}
}
} else if (resource === 'campaign') {
Expand All @@ -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') {
Expand Down

0 comments on commit ec87777

Please sign in to comment.