我不明白为什么一个简单的 fetch 请求通过 Vanilla JS 不成功,但通过 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();
响应是Request Failed TypeError: Failed to fetch。DBID 和 SECRET 都是正确的。