Edits history of script submission #23069 for ' Retrieve Block (notion)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Retrieve Block
     * Get a single block by ID. A page ID also works, returning the page as a child_page block.
     */
    export async function main(auth: RT.Notion, block_id: string) {
      const response = await fetch(`https://api.notion.com/v1/blocks/${block_id}`, {
        headers: {
          Authorization: `Bearer ${auth.token}`,
          Accept: "application/json",
          "Notion-Version": "2026-03-11",
        },
      })
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 3 days ago