\"JSON Parse error: Unrecognized token\'<\'\" Error is showing while hitting the api. Code is attached below Note* : Response is in the JSON format.
You can try by adding the headers to your fetch api, as it posts your record to your url.
var dataObj = {}
dataObj.uname = uname,
dataObj.password = password
fetch("http:/example.com", {
method: 'post',
headers: {
'Accept': 'application/json, text/plain, */*', // It can be used to overcome cors errors
'Content-Type': 'application/json'
},
body: JSON.stringify(dataObj)
})
.then((response) => response.json())
.then((responseData) => {
AlertIOS.alert(
"POST Response",
"Response Body -> " + JSON.stringify(responseData.body)
)
}).done();
this.props.navigation.navigate("Home")
};