notion-api icon indicating copy to clipboard operation
notion-api copied to clipboard

Cannot get expect Html

Open dxcqcv opened this issue 5 years ago • 3 comments
trafficstars

I run notion-api-js in nodejs, but I cannot get right html content

expect html is like that

<div>music-song</div>
...
and so on

but return cotent is


[ { HTML:
     '<div><h1 >Get Started</h1><p>👋 Welcome! This is a private page for you to play around with. </p><br /><p>Give these things a try:</p><br /><br /><p style="color:undefined">Have a question?</p></div>',
    Attributes:
     { title: 'Get Started',
       slug: 'get-started',
       cover: null,
       teaser:
        'Get Started 👋 Welcome! This is a private page for you to play around with.  Give these things a try: Have a question?',
       icon: null,
       id: '9bdfefb9-56af-4a3c-b21e-4301a99f6994' } },

so the return html content is total wrong? and I also use Token, why cannot get right html content?

my code is

// require syntax
const Notion = require("notion-api-js").default;


const pageUrl = "https://www.notion.so/2628769120ad41d998ec068d6e2eb410?v=e8e69ac68a8d483792c54541e4d8ba72"
const token = "acf60ab1255a12c6c101e5beb6b776a767c25a2339ea86f0d5ac5a9abc25cbb7c1e27f439adbd9cdae1bb717f02ccf739dc694c42c86018f7b136b81ce2bbcdda4f1abd6672489231d2f3835c16c"

const notion = new Notion({
  token ,
  options: {
    pageUrl 
  }
});

notion.getAllHTML().then(html => {
  // Your Code here
  console.log(html)
});

dxcqcv avatar Mar 10 '20 10:03 dxcqcv

I'll have a look at this some time this week.

Aceto1 avatar Mar 24 '20 09:03 Aceto1

I also get JSON instead of full HTML. And also, in the JSON, there's no workspace part.. It seems like it only gets private things.

chanjungkim avatar May 22 '20 03:05 chanjungkim

@dxcqcv Hi there, sorry for the inactivity! You are using the pageUrl property in a wrong way. To get the data for a certain page you need to call the getPageById method :)

cstrnt avatar Feb 11 '21 13:02 cstrnt