Skip to content

Instantly share code, notes, and snippets.

@dealingwith
Created May 20, 2021 03:39
Show Gist options
  • Select an option

  • Save dealingwith/99c4da33565dddb115b5c173e1e29f48 to your computer and use it in GitHub Desktop.

Select an option

Save dealingwith/99c4da33565dddb115b5c173e1e29f48 to your computer and use it in GitHub Desktop.
let notionToken = await env('NOTION_USER_TOKEN')
let databaseID = "3859b567fda3464ea5a69d5ccb56274b"
let content = await arg('Enter Task')
let {data} = await post(
'https://api.notion.com/v1/pages', {
"parent": { "database_id": databaseID },
"properties": {
"Name": {
"title": [
{
"text": {
"content": content
}
}
]
}
}
},
{
headers: {
Authorization: `Bearer ${notionToken}`,
"Content-Type": "application/json",
"Notion-Version": "2021-05-13"
}
})
let bodyContent = await arg('Enter Content')
let {bodyData} = await patch(
`https://api.notion.com/v1/blocks/${data.id}/children`, {
"children": [
{
"object": "block",
"type": "paragraph",
"paragraph": {
"text": [
{
"type": "text",
"text": {
"content": bodyContent
}
}
]
}
}
]
},
{
headers: {
Authorization: `Bearer ${notionToken}`,
"Content-Type": "application/json",
"Notion-Version": "2021-05-13"
}
})
let pageID = data.id.replace(/-/g, "");
let pageURL = `https://notion.so/${databaseID}?p=${pageID}`
copy(pageURL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment