ijjk / notion-blog

A Next.js site using new SSG support with a Notion backed blog
https://notion-blog.vercel.app
MIT License
3.7k stars 536 forks source link

Notion API has changed #78

Closed tomoyamachi closed 3 years ago

tomoyamachi commented 3 years ago

The NotionAPI (unofficial) has changed its interface, so blog pages can no longer be retrieved.

https://notion-blog.vercel.app/blog

e.g : https://github.com/ijjk/notion-blog/blob/b35fcbc5c52d93bb7af8400a3f15d197690f8b48/src/lib/notion/createTable.js#L328-L341

# current version
  const res = await fetch(`${API_ENDPOINT}/loadPageChunk`, {
    method: 'POST',
    headers: {
      cookie: `token_v2=${NOTION_TOKEN}`,
      'content-type': 'application/json',
    },
    body: JSON.stringify({
      pageId,
      limit: 25,
      cursor: { stack: [] },
      chunkNumber: 0,
      verticalColumns: false,
    }),
  })

# fixed version
  const res = await fetch(`${API_ENDPOINT}/loadCachedPageChunk`, {
    method: 'POST',
    headers: {
      cookie: `token_v2=${NOTION_TOKEN}`,
      'content-type': 'application/json',
    },
    body: JSON.stringify({
      page: { id : pageId },
      limit: 25,
      cursor: { stack: [] },
      chunkNumber: 0,
      verticalColumns: false,
    }),
  })
mmattm commented 3 years ago

Look's like It doesn't work anymore for me either.

Do you have a fix for other library requests ?

FarazPatankar commented 3 years ago

The change isn't what the OP has mentioned. I might make a PR over the weekend but if anyone wants to fix it before then, here's a commit with the changes required to get the blog to work again.

https://github.com/railwayapp/blog/commit/78c5db89fe01543f6a053e1736a584d7bb7964a4

ijjk commented 3 years ago

Closing as this has been updated in https://github.com/ijjk/notion-blog/commit/2125d085c1770590954c503a04310e65fd42af76, thanks @FarazPatankar for investigating!