I’m engaged on a React Native app with the Expo framework. I used to be capable of create a improvement shopper and put in it on my iOS gadget. The app appears to work, at the very least I can open the app and go to the login circulate.
Nonetheless, I when I attempt to log in, it fails as:
LOG Sending request to: http://127.0.0.1:5000/api/v1/verify_user.json
ERROR Community request failed: [TypeError: Network request failed]
Listed below are issues I do know:
- No problem on the endpoint.
> curl -H "Content material-Sort: utility/json" -X POST "http://127.0.0.1:5000/api/v1/verify_user.json" -d '{"person":{"electronic mail":"[email protected]","is_verified":true}}'
{"success":true}%
- Login works on the net half with none points.
Nonetheless, in relation to iOS app, issues begin to break. Right here is the operate accountable for the cellular log in on ContinueWithEmail.tsx
:
const verifyUserEmail = async (electronic mail: string) => {
const authEndpoint="http://127.0.0.1:5000/api/v1/verify_user.json";
strive {
console.log('Sending request to:', authEndpoint);
const response = await fetch(authEndpoint, {
technique: 'POST',
headers: {
Settle for: 'utility/json',
'Content material-Sort': 'utility/json',
},
physique: '{"person":{"electronic mail":"[email protected]","is_verified":true}}',
});
console.log('Response standing:', response.standing);
const responseData = await response.json();
console.log('Response knowledge:', responseData);
if (response.okay) {
if (electronic mail && me && Platform.OS !== 'internet')
if (electronic mail !== me.electronic mail) {
AsyncStorage.setItem('special_offer', '');
clearCache && clearCache();
}
if (!(!!errors.electronic mail && !isValid)) {
navigation.navigate('continue-with-email-password');
}
} else if (responseData.auth_provider) {
if (Platform.OS === 'internet') {
setShowProviderModal(true);
setErrorName(responseData.error);
}
Alert.alert(
m('onBoarding.error.title'),
responseData?.error,
[
{
text: m('onBoarding.error.errorMsg', {
provider: responseData.auth_provider,
}),
onPress: () => loginPress(),
},
{
text: 'Dismiss',
onPress: () => {},
},
],
{
cancelable: true,
}
);
} else if (responseData.error) {
setErrors({ electronic mail: responseData?.error });
}
} catch (error) {
console.error('Community request failed:', error);
Alert.alert(
'Community Error',
'There was an issue connecting to the server. Please verify your web connection and check out once more.'
);
}
};
As I’m not a cellular developer, I’m just about clueless on the right way to debug this. Any pointers could be extremely appreciated!