"multipart! = application / json" displays an error message on android (react-native)

I have an application that is built using native-native and works fine on iOS.

I make it also available for Android, but there is an error when trying to send 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); }); 

enter image description here

+6
source share
1 answer

you need to change the "Content-Type" to

 'Content-Type': 'multipart/form-data' 
+17
source

All Articles