Add parent id to children blocks on Notion node (#2850)

* [Notion] Adds possibility to return blocks as an array

*  add parent id to response

Co-authored-by: Ugo Bataillard <ugopublic@bataillard.me>
This commit is contained in:
Ricardo Espinoza 2022-02-24 11:32:45 -05:00 committed by GitHub
parent db2af7effb
commit 4df958807d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -241,6 +241,7 @@ export class NotionV2 implements INodeType {
for (let i = 0; i < length; i++) {
const blockId = extractPageId(this.getNodeParameter('blockId', i) as string);
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
if (returnAll) {
responseData = await notionApiRequestAllItems.call(this, 'results', 'GET', `/blocks/${blockId}/children`, {});
} else {
@ -248,6 +249,9 @@ export class NotionV2 implements INodeType {
responseData = await notionApiRequest.call(this, 'GET', `/blocks/${blockId}/children`, {}, qs);
responseData = responseData.results;
}
responseData = responseData.map((_data: IDataObject) => ({ object: _data.object, parent_id: blockId, ..._data }));
returnData.push.apply(returnData, responseData);
}
}