0
kiran posted
react-native fetch post body is not passing to server
fetch('http://java.com/test.php?d=data',{
method:'POST',
mode: 'same-origin',
credentials: 'include',
redirect: 'follow',
body:JSON.stringify({username:'test',password:'test'}),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
}).then((response)=>{
if(response.status >= 200 && response.status < 300){
return response;
}else{
var error = new Error(response.statusText);
error.response = response;
throw error;
}
}).then((response)=>{
return response.json();
}).then((data)=>{
console.log(data);
/* Process data */
}).catch((error)=>{
/* Catch Error */
});
in server with php
for print_r($_REQUEST) i only found GET parameter not any POST parameter .
i tried many way but it is not working