I don't understand why a simple fetch request is unsuccessful via Vanilla JS but successful via Postman:
const getNotion = () => {
fetch(
"https://api.notion.com/v1/databases/[DBID_HERE]",
{
method: "GET",
headers: {
"Authorization": "Bearer [SECRET_HERE]",
"Notion-Version": "2021-05-11"
}
}
)
.then((response) => response.json())
.then((json) => {
console.log(json);
})
.catch((err) => console.log("Request Failed", err));
};
getNotion();
The response is Request Failed TypeError: Failed to fetch. Both DBID and SECRET are correct.