微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

React Native:https 请求上的 Axios 网络错误

如何解决React Native:https 请求上的 Axios 网络错误

我正在尝试使用 React-Native 中的 Axios 框架从定制的 API 中获取数据。 在 iOS 上一切正常。但是在 Android 设备(不是模拟器)上,我总是收到“网络错误”消息。

请求网址:https://subdomain.mydomain.de/xxxx/xxx.php (GET)

我还在我的域中将 android:networkSecurityConfig="@xml/network_security_config" 添加Android 清单(调试和发布)。

我的network_security_config.xml 如下所示:

<network-security-config>
    <!-- deny cleartext traffic for React Native packager ips in release -->
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">localhost</domain>
        <domain includeSubdomains="true">10.0.2.2</domain>
        <domain includeSubdomains="true">10.0.3.2</domain>
        <domain includeSubdomains="true">mydomain.de</domain>
    </domain-config>
</network-security-config>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。