Reputation: 761
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