Skip to content

Unable to copy a page and have it save #519

Description

@ParthGandhi

Context

I have a nested database with some rows. I want to script creating a new row by coping an existing row OR by using a template.

Describe the bug
Unable to copy a page and have it save

To Reproduce
I first tried to do this outside of a database, just for a regular page but couldn't get it to work.

import { NotionCore } from "@nishans/core";

const nishan = new NotionCore.Api.Nishan({
  token: "XXXXX",
  logger: true,
});

(async () => {
  const pageId = "some-UUID";
  const pages = await nishan.getPagesById([pageId]);
  const page = pages.page.get(pageId);
  const res = await page?.duplicate(1);
  console.log(res);
})();

It outputs some JSON, but I can't find the relevant page on notion or where its copied to. Any ideas on how to do this correctly?

2 additional questions:

  1. Is there a way to create a new row in a collection/database using a template? Or copy a row in a database into a new row?
  2. Is there a full working example I can use as a reference?
  3. Could you update the discord invite? The current link everywhere is invalid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions