I have an app which is builded with react-native and it's running perfectly in iOS.
I am making it also available for Android but there is a error when trying to post contact form data to my server.
var formData = new FormData()
formData.append('name', fullname)
formData.append('email', email)
formData.append('message', message + ' -- Sent from Android app')
fetch('https://www.xxxx.com/mail', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: formData
}).then((response) => response.json())
.then((data) => {
if (data.success
...
else
...
})
.catch((error) => {
console.warn(error);
});
you have to change the 'Content-Type' to
'Content-Type': 'multipart/form-data'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With