I am getting this error as a network request is sent using fetch while the device is offline.
It is working fine if device has a working internet connection but as I disable the internet, Instead of getting in catch, the app throws this error. I am using an android device.
This is my code snippet:
export const sendOTP = (phone, successCallback, failedCallback) => dispatch => {
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
phone: '91'+phone,
})
})
.then((response) => response.json())
.then((res) => {
if(res.success) {
dispatch({type: ADD_PHONE_NUMBER, payload: { phone:'91'+ phone }});
successCallback();
}
})
.catch((err) => {
failedCallback();
})
}
I think it’s an issue in React Native 0.55
Can anyone guide me how to fix this?