Api 在react native中将数据提取到数据库时出现问题。错误:";json解析错误无法识别的令牌'<'&引用;
在标题中,您可以尝试将内容类型更改为Api 在react native中将数据提取到数据库时出现问题。错误:";json解析错误无法识别的令牌'<'&引用;,api,react-native,fetch,Api,React Native,Fetch,在标题中,您可以尝试将内容类型更改为“application/json” 这回答了你的问题吗?JSON分析错误:无法识别的令牌' try { return fetch('http://mylinktoAPI', { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Typ
“application/json”
这回答了你的问题吗?JSON分析错误:无法识别的令牌'
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);
}
};
"Content-Type", "application/json"