Skip to content

Commit 9faa93d

Browse files
committed
[Add] 노션 데이터베이스 추가 기능 구현
1 parent 2db4e2b commit 9faa93d

File tree

4 files changed

+271
-0
lines changed

4 files changed

+271
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/node_modules
2+
databaseKEY

index.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { Client } from "@notionhq/client"
2+
3+
const notion = new Client({ auth: process.env.NOTION_KEY })
4+
5+
const databaseId = process.env.NOTION_DATABASE_ID
6+
7+
// console.log(notion);
8+
// console.log(databaseId)
9+
10+
async function addItem(text) {
11+
try {
12+
const response = await notion.pages.create({
13+
parent: { database_id: databaseId },
14+
properties: {
15+
title: {
16+
title:[
17+
{
18+
"text": {
19+
"content": text
20+
}
21+
}
22+
]
23+
}
24+
},
25+
})
26+
console.log(response)
27+
console.log("Success! Entry added.")
28+
} catch (error) {
29+
console.error(error.body)
30+
}
31+
}
32+
33+
addItem("Yurts in Big Sur, California")

package-lock.json

+225
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "automatednotion",
3+
"type": "module",
4+
"version": "1.0.0",
5+
"description": "",
6+
"main": "index.js",
7+
"dependencies": {
8+
"@notionhq/client": "^2.2.3"
9+
}
10+
}
11+

0 commit comments

Comments
 (0)