You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在创建Notion页面时返回并打印页面唯一ID

获取Notion新创建页面的唯一ID

notion.pages.create()方法执行后会返回新创建页面的完整数据对象,其中就包含该页面的唯一ID。你只需要将这个返回值存储到变量中,再提取并打印id字段即可。

修改后的代码如下:

const newPage = await notion.pages.create({
  parent: {
    database_id: process.env.EVENTS_DATABASE_ID,
  },
  properties: {
    Name: {
      title: [
        {
          text: {
            content: name,
          },
        },
      ],
    },
    Description: {
      rich_text: [
        {
          text: {
            content: "some words here...",
          },
        },
      ],
    },
  },
})

// 打印新页面的唯一ID
console.log(newPage.id)

返回的newPage对象里的id字段就是刚创建页面的唯一标识,直接输出这个值就能得到你要的结果。

内容的提问来源于stack exchange,提问作者alagilly

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 23:24:50