So i'm developing a ReactNative App, and to create a new user, i'm creating a Json with the informations given by the user, and i send it to a PhP file which Parse the Json received to store it in the Database. But the problem is that my JSON doesn't send, and i have this magnificent Red Screen "JSON Parse Error : Unexpected EOF" If you guys have a solution for me, that would be wonderful after long nights of debug ..
Here is my code for the Fetch :
Insert_Data_Into_MySQL = () =>
{
this.setState({ ActivityIndicator_Loading : true }, () =>
{
fetch('http://MyPathToMyServerButDontWorryItsAnExample/NewUser.php',
{
method: 'POST',
headers:
{
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(
{
product_name : this.state.Product_Name,
product_number : this.state.Product_Number,
product_details : this.state.Product_Details
})
})
.then((response) => response.json()).then((responseJsonFromServer) =>
{
Alert.alert(responseJsonFromServer);
this.setState({ ActivityIndicator_Loading : false });
}).catch((error) =>
{
console.error(error);
this.setState({ ActivityIndicator_Loading : false});
});
});
}
Thank's a lot guys !