使用对 API 的 post 请求时出现这 2 个错误(使用 chrome)
xhr.js:178 POST MY_API_URL net::ERR_HTTP2_PROTOCOL_ERROR createError.js:16 Uncaught (in promise) Error: Network Error at createError (createError.js:16) at XMLHttpRequest.handleError (xhr.js:83)
我正在做一个简单的 POST 请求(反应代码):
const postData = async()=>{
let res = await Axios.post('/terrenos', {'idTerreno':'0'} );
console.log( res.data );
}
Run Code Online (Sandbox Code Playgroud)
而在 API 方面,我只有这个用于调试(PHP 代码):
if( $_SERVER["REQUEST_METHOD"] === 'GET'){
main($_GET);
}else if( $_SERVER["REQUEST_METHOD"] === 'POST'){
echo(json_encode($_POST));
}
Run Code Online (Sandbox Code Playgroud)
当我不在正文中发送任何内容时,它工作得很好(它返回一个空数组)
const postData = async()=>{
let res = await
Axios.post('https://gpgpy.000webhostapp.com/papaProject/API/v2/query.php');
console.log( res.data );
}
Run Code Online (Sandbox Code Playgroud)
当我将邮递员用于相同的请求时,无论有没有身体,它也可以工作。