mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-22 12:19:09 +00:00
feat(Notion Node): Fetch child blocks recursively (#7304)
Github issue / Community forum post (link here to close automatically):
This commit is contained in:
@@ -24,6 +24,7 @@ import {
|
||||
mapSorting,
|
||||
notionApiRequest,
|
||||
notionApiRequestAllItems,
|
||||
notionApiRequestGetBlockChildrens,
|
||||
simplifyObjects,
|
||||
validateJSON,
|
||||
} from '../GenericFunctions';
|
||||
@@ -273,6 +274,7 @@ export class NotionV2 implements INodeType {
|
||||
this.getNodeParameter('blockId', i, '', { extractValue: true }) as string,
|
||||
);
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
const fetchNestedBlocks = this.getNodeParameter('fetchNestedBlocks', i) as boolean;
|
||||
|
||||
if (returnAll) {
|
||||
responseData = await notionApiRequestAllItems.call(
|
||||
@@ -282,8 +284,13 @@ export class NotionV2 implements INodeType {
|
||||
`/blocks/${blockId}/children`,
|
||||
{},
|
||||
);
|
||||
|
||||
if (fetchNestedBlocks) {
|
||||
responseData = await notionApiRequestGetBlockChildrens.call(this, responseData);
|
||||
}
|
||||
} else {
|
||||
qs.page_size = this.getNodeParameter('limit', i);
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
qs.page_size = limit;
|
||||
responseData = await notionApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
@@ -291,7 +298,13 @@ export class NotionV2 implements INodeType {
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.results;
|
||||
const results = responseData.results;
|
||||
|
||||
if (fetchNestedBlocks) {
|
||||
responseData = await notionApiRequestGetBlockChildrens.call(this, results, [], limit);
|
||||
} else {
|
||||
responseData = results;
|
||||
}
|
||||
}
|
||||
|
||||
responseData = responseData.map((_data: IDataObject) => ({
|
||||
|
||||
Reference in New Issue
Block a user