Reputation: 21846
I am using the following fetch call in a react native app:
fetch(apiUrls.signInUrl, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
user: {
email: username,
password: password,
}
})
})
.then(response => {
response.json().then(responseJson => {
dispatch(AccountActions.loginResponse(username, password, responseJson.token, response.status));
dispatch(CardActions.getCards(username, responseJson.token));
});
})
.catch(err => {
console.error(err);
});
The fetch call is failing with the following error screen. Any help?
Upvotes: 0
Views: 694
Reputation: 2692
In IOS http connections are disabled by default. So you would have to enable it. Though it isn't recommended, it should be fine for debug mode.
Here are the steps: 1. You go to Info.plist file of your iOS project in Xcode
Optionally you can also add your trusted host to exception domains if you don't like to enable "allow arbitrary loads" option
Good luck!
Upvotes: 1