From 92a2e863f3d66a26ac997ddf87ec2d1123578377 Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Tue, 22 Jun 2021 17:59:04 -0400 Subject: [PATCH] :bug: Fix bug paginating databases and users (#1907) --- packages/nodes-base/nodes/Notion/GenericFunctions.ts | 9 +++++++-- packages/nodes-base/nodes/Notion/Notion.node.ts | 2 -- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/nodes-base/nodes/Notion/GenericFunctions.ts b/packages/nodes-base/nodes/Notion/GenericFunctions.ts index 91664ae935..01f03261dd 100644 --- a/packages/nodes-base/nodes/Notion/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Notion/GenericFunctions.ts @@ -52,6 +52,8 @@ export async function notionApiRequest(this: IHookFunctions | IExecuteFunctions export async function notionApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any + const resource = this.getNodeParameter('resource', 0) as string; + const returnData: IDataObject[] = []; let responseData; @@ -59,8 +61,11 @@ export async function notionApiRequestAllItems(this: IExecuteFunctions | ILoadOp do { responseData = await notionApiRequest.call(this, method, endpoint, body, query); const { next_cursor } = responseData; - query['start_cursor'] = next_cursor; - body['start_cursor'] = next_cursor; + if (resource === 'block' || resource === 'user') { + query['start_cursor'] = next_cursor; + } else { + body['start_cursor'] = next_cursor; + } returnData.push.apply(returnData, responseData[propertyName]); if (query.limit && query.limit <= returnData.length) { return returnData; diff --git a/packages/nodes-base/nodes/Notion/Notion.node.ts b/packages/nodes-base/nodes/Notion/Notion.node.ts index ee6992a64b..5ae2fe06c1 100644 --- a/packages/nodes-base/nodes/Notion/Notion.node.ts +++ b/packages/nodes-base/nodes/Notion/Notion.node.ts @@ -47,7 +47,6 @@ import { databasePageFields, databasePageOperations, } from './DatabasePageDescription'; -import { getServers } from 'dns'; export class Notion implements INodeType { description: INodeTypeDescription = { @@ -323,7 +322,6 @@ export class Notion implements INodeType { if (operation === 'getAll') { for (let i = 0; i < length; i++) { const body: IDataObject = { - page_size: 100, filter: { property: 'object', value: 'database' }, }; const returnAll = this.getNodeParameter('returnAll', i) as boolean;