Ricardo Vargas
Ricardo Vargas

Reputation: 761

Can I use fetch to call the Notion API?

I want to use Notion as a content gateway for a SPA. Can I use the Notion API from fetch? I'm trying to use fetch to get the data but It's not working because of CORS.

let notion = fetch(import.meta.env.VITE_NOTION_API_URL+'/databases/'+import.meta.env.VITE_NOTION_APP_DATABASE+'/query', {
      method: 'POST',
      mode: 'cors',
      credentials: 'omit',
      headers: {
        'Content-Type': 'application/json',
        "Authorization": `Bearer ${import.meta.env.VITE_NOTION_API_SECRET}`,
        "Notion-Version": `${import.meta.env.VITE_NOTION_API_VERSION}`,
      }
    })

It's this possible?

Upvotes: 6

Views: 2740

Answers (1)

adlopez15
adlopez15

Reputation: 4417

No. The Notion API does not support CORS.

Upvotes: 8

Related Questions