我的react native 代码如下:
fetch('https://www.lisonblog.cn/apptest/test.php',{
methos: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
postData:'lalala'
})
}).then(function(res) {
alert(res.status)
if (res.status === 200) {
return res.json()
} else {
return Promise.reject(res.json())
}
}).then(function(data) {
alert(data)
}).catch(function(err) {
alert(err);
});
我的后端的PHP代码是这样的:
最后在手机APP上弹出这个错误:TypeError:Body not allowed for GET or HEAD requests

请问是什么原因?我看网上有的需要传输的数据是formData类型的,求大神赐教
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
第2行,应该是method,不是methos
应该使用
postData='lalala',跟jquery查找规则相关,具体可再了解。