try {
return fetch('http://mylinktoAPI', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded',
},
body: JSON.stringify({
first_name: this.state.first_name,
last_name: this.state.last_name,
gender: this.state.gender,
blood_group: this.state.blood_group,
phone: this.phone,
email: this.email,
address: this.address,
}),
}).then((response) => response.json())
.then((responseJson) => {
Alert.alert(responseJson);
}).catch((error) => {
console.error(error);
});
} catch (e) {
console.error('fetch catch error', e);
}
};
-
2Does this answer your question? JSON Parse error: Unrecognized token'<' - react-nativevahdet– vahdet2020-02-12 06:32:47 +00:00Commented Feb 12, 2020 at 6:32
Add a comment
|