asnunes / notion-page-to-html

NodeJS tool to convert public Notion pages to HTML from page ID
MIT License
161 stars 42 forks source link

Unexpected token e in JSON at position 0 #18

Closed kennedyrose closed 2 years ago

kennedyrose commented 2 years ago

I'm getting the following error:

SyntaxError: Unexpected token e in JSON at position 0
    at JSON.parse (<anonymous>)
    at IncomingMessage.<anonymous> (/node_modules/notion-page-to-html/dist/utils/usecases/http-get/node-http-get.js:74:44)
    at IncomingMessage.emit (node:events:406:35)
    at endReadableNT (node:internal/streams/readable:1329:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

When trying to use it with this page:

https://www.notion.so/smarterlabs/Setting-Up-a-New-Vercel-Website-584a1c27a10642d8869473588a5c1b45

I can get it to work just fine with the example page you have in the readme. So I'm assuming it's something on that page the notion-page-to-html module doesn't support.

asnunes commented 2 years ago

Hi, @kennedyrose, sorry for the late reply. This URL leads to a redirect page instead of the original page, so the lib faces an error when trying to fetch page content. Pointing to a plain public Notion page should fix the problem. These redirect pages are not supported, but this error message is not clear, so I released a new version #21 that handles this error properly by throwing the following message

NotionPageNotFound: Can not find Notion Page of id 584a1c27-a106-42d8-8694-73588a5c1b45. Is the url correct? It is the original page or a redirect page (not supported)?

Thank you for your report!