juliariec / comments

Comments for juliariec.com.
MIT License
0 stars 0 forks source link

blog/export-kobo-to-notion/ #11

Open utterances-bot opened 2 weeks ago

utterances-bot commented 2 weeks ago

How to export Kobo highlights to Notion with Node and better-sqlite3 · julia rodenburg

Using the Notion API and better-sqlite3 to export Kobo highlights to Notion.

https://www.juliariec.com/blog/export-kobo-to-notion/

jessicaliang721 commented 2 weeks ago

How are you able to run:

const response = await notion.databases.query({
  database_id: NOTION_DATABASE_ID,
  filter: {
    property: "Title",
    text: {
      equals: "Circe",
    },
  },
})
console.log(response)
})()

I get the error "SyntaxError: await is only valid in async functions and the top level bodies of modules" even though I'm running Node.js v20.12.0. I tried adding

{ "type": "module" }

to package.json to no avail.

juliariec commented 1 week ago

Good catch! I just updated the post with a functional version, it works if you wrap it in an async function like this:

async function exportHighlights() {
  const response = await notion.databases.query({
    database_id: NOTION_DATABASE_ID,
    filter: {
      property: "Title",
      rich_text: {
        equals: "Circe",
      },
    },
  })
  console.log(response)
}

exportHighlights()