Last active
December 20, 2022 02:34
-
-
Save sakirtemel/b75967fa8b76f9d6ecc8bb0c39c2dc05 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Client } = require("@notionhq/client"); | |
const notionNewsDatabaseId = process.env.NOTION_NEWS_DATABASE_ID; | |
const allNews = await notion.databases.query({ | |
database_id: notionNewsDatabaseId, | |
}); | |
let fetchedNews = []; | |
for (const newsObject of allNews["results"]){ | |
const content = JSON.stringify(await notion.blocks.children.list({ | |
block_id: newsObject["id"], | |
page_size: 100, | |
})).results); | |
const newsItem = { | |
id: newsObject["id"], | |
title: newsObject["properties"]["Title"]["title"][0]["plain_text"], | |
content: content, | |
} | |
fetchedNews.push(newsItem); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment