I am using fetch
in react native
application to send a post request as:
const data = {
name: 'name',
email: 'email'
}
try{
var r = await fetch(SEND_INITIAL_DATA, {
method: 'POST',
body: JSON.stringify(data),
headers:{
'Content-Type': 'application/json'
}
});
}catch(err){
console.log(err);
}
console.log(r);
I am using php in my backend server. but I am unable to access the parameters in php and printing the $_POST
is missing body
PHP :
<?php
require 'connect.php';
echo json_decode($_POST); // printing the post
RESPONE
What am I missing ?