我對 Firebase 上的 Cloud Functions 有一個 POST 請求。當我嘗試發出請求時,我收到了 CORS 策略錯誤。好的,我設定 mode: 'no-cors' 并獲取Failed to load resource: the server responded with a status of 500 ().
這是代碼
let myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Accept", "application/json");
let raw = JSON.stringify({
"description": "Test item",
"email": "[email protected]"
});
let requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
mode: 'no-cors',
redirect: 'follow',
};
fetch("https://someURl.cloudfunctions.net/someRequest", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
代碼是從 Postman 復制的
有任何想法嗎?
uj5u.com熱心網友回復:
正如jaba所證實的,問題出在服務器端。此外,這里也有同樣的記錄。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/440136.html
標籤:javascript 火力基地 邮政 谷歌云功能
