I tried to do a fetch on a URL that is working when I use on postman, but when I try to do the same on react native (after doing the same procedure on different URLs) I got an error saying JSON Parse error: Unregonized token '<' that seems to be because the programs fails to convert the HTML response into JSON using the .json(). Here's the code I'm currently running:
GetMonthData = async () => {
let UserID = await AsyncStorage.getItem('userID');
this.setState({ UserID: UserID })
return fetch('https://guardianes.centeias.net/user/calendar/month', {
method: 'GET',
headers: {
user_id: this.state.UserID,
}})
.then((response) => response.json())
.then((responseJson) => {
this.setState({
isLoading: false,
dataSource: responseJson.data,
}, function(){
});
})
.catch((error) =>{
console.error(error);
});
Here's the error I get while running the app on device
The problem is that I searched a lot already and can't seem to find a solution. Thanks for any help.