Edits history of script submission #23134 for ' Retrieve Database (notion)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Retrieve Database
     * Get a database by the ID in its URL. Its `data_sources` list gives the data source IDs that Query Data Source and Create Page need.
     */
    export async function main(auth: RT.Notion, database_id: string) {
      const response = await fetch(
        `https://api.notion.com/v1/databases/${database_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 4 hours ago