【发布时间】:2021-11-24 05:11:29
【问题描述】:
我使用“axios”库来获取数据。它在新的 Android 设备(Android 9 和 10)上运行完美,但在旧设备(Android 7 或更低版本)上总是出现如下网络错误:[错误:网络错误] 设备似乎无法与https 网址。
这个问题是下面这个链接的重复我也收到这个错误任何人都可以帮忙。
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,
},
});
};
【问题讨论】:
-
嘿,您是否尝试过共享链接上的解决方案?确保你在之后重建 APK - React native 可能会有点时髦,所以在 Android Studio 中进行以确保。如果这些解决方案不起作用,我们需要查看您的代码和端点
-
是的,我已经尝试过该链接中给出的解决方案,但没有奏效。问题是它在新的 android 设备上运行良好,但在旧设备上却不行。
标签: javascript android reactjs react-native axios