I used 'axios' library to fetch the data. It is working perfect on new Android devices (Android 9 & 10) but on old devices (Android 7 or less) it always gives Network Error like this: [ Error: Network Error] it seems like the devices could not establish a connection with the https URL.
This question is duplicate of this link below I am also getting this error can anyone help out.
Fix APIs connection problem with old Android OS (Android 7 or less) in React Native using axios
const SERVER_URL = 'https://*****.com/****';
export const getCities = () => async dispatch => {
let res = await axios.get(`${SERVER_URL}/GetCityList`);
res = parser.parse(res.data).ArrayOfMCity.mCity;
if (res && !res.length) {
res = [res];
}
const dropdownCities = [];
res.forEach(r => {
dropdownCities.push({label: r.CityName, value: r.CityID});
});
dispatch({
type: GET_CITY,
payload: {
cities: res ? res : [],
dropdownCities,
},
});
};
Well I got the solution I have tried other api other than my api and it is working perfectly. So I found out that I am having a certificate issue in android old devices. The certificate is not working in old devices from version 7.1 and older.
Here is the link which says that many websites will stop working in older android devices from 1st September 2021