mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
🐛 Fix bug paginating databases and users (#1907)
This commit is contained in:
parent
c21c8b3369
commit
92a2e863f3
|
@ -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<any> { // 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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue