Asked 24 days ago
28 Dec 2017
Views 60
kiran

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
Post Answer