1

Append Block Children

by
Published Jun 6, 2022
Script notion Verified

The script

Submitted by hugo989 Bun
Verified 6 days ago
1
import { Client } from "@notionhq/client";
2
import type { BlockObjectRequest } from "@notionhq/client/build/src/api-endpoints";
3

4
/**
5
 * Learn more at
6
 * https://developers.notion.com/reference/patch-block-children
7
 */
8
type Notion = {
9
  token: string;
10
};
11
export async function main(
12
  auth: Notion,
13
  block_id: string,
14
  children: object[] = [],
15
) {
16
  const client = new Client({ auth: auth.token });
17
  return await client.blocks.children.append({
18
    block_id,
19
    children: children as BlockObjectRequest,
20
  });
21
}
22

Other submissions
  • Submitted by adam186 Deno
    Created 398 days ago
    1
    import { Client } from "npm:@notionhq/client";
    2
    import type { BlockObjectRequest } from "npm:@notionhq/client/2.2.4/build/src/api-endpoints.js";
    3
    
    
    4
    /**
    5
     * Learn more at
    6
     * https://developers.notion.com/reference/patch-block-children
    7
     */
    8
    type Notion = {
    9
      token: string;
    10
    };
    11
    export async function main(
    12
      auth: Notion,
    13
      block_id: string,
    14
      children: object[] = [],
    15
    ) {
    16
      const client = new Client({ auth: auth.token });
    17
      return await client.blocks.children.append({
    18
        block_id,
    19
        children: children as BlockObjectRequest,
    20
      });
    21
    }
    22