Skip to content

Instantly share code, notes, and snippets.

@sakirtemel
Last active December 20, 2022 02:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sakirtemel/b75967fa8b76f9d6ecc8bb0c39c2dc05 to your computer and use it in GitHub Desktop.
Save sakirtemel/b75967fa8b76f9d6ecc8bb0c39c2dc05 to your computer and use it in GitHub Desktop.
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