[英]415 Unsupported Media Type React Fetch Api
當我單擊按鈕結果是 415 媒體類型錯誤。 當我刪除模式:'no-cors'時,我看到 CORS 錯誤和 405 登錄錯誤,但我可以檢查 postman 沒問題 URL。
結果應該是真或假。 TypeError:無法在“Window”上執行“fetch”:提供的值“*cors”不是 RequestMode 類型的有效枚舉值。
const LoginForm = () => {
const router = useRouter()
const { t } = useLocalizationContext()
const [email,setEmail] = useState('');
const [password,setPassword] = useState('');
const submit = async (e:SyntheticEvent) => {
e.preventDefault();
await fetch('url/api/v1/users/login',{
mode:'no-cors',
method: 'POST',
headers:
{
'Accept': 'application/json',
'Content-Type': 'application/json',
},
credentials:'include',
body:JSON.stringify({
email,
password})
});}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.