react-native-android - react-native android:可能的未处理承诺拒绝(id:0):TypeError:网络请求失败
问题描述
我正在尝试调用 fetch request 并且它在 Ios 中运行良好但是当我在我的 android 设备中运行时出现错误
let CONVERT_FILE = "https://myUrl/convertFile";
const response = await fetch(CONVERT_FILE, {
method: "POST",
headers: utils.getApplicationHeaders(token),
body:res
})
console.log("response",response)
const json = await response.json();
console.log("JSON",json)
return json;
我也尝试添加 AndroidManifest.xml
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config"
在 network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true"/>
</network-security-config>
错误是
Possible Unhandled Promise Rejection (id: 0): TypeError: Network request failed
解决方案
推荐阅读
- java - 如何在android上以编程方式自动接听来电
- db2 - DBeaver 是否支持 IDAA 查询加速?
- jquery - 在函数中将 jquery 添加到 wordpress?
- c++ - 两种情况下的输出不应该相同吗?
- oracle - 是什么原因导致“如果绑定大于请求或支持 bean 范围,则可能导致不一致。” ADF 中的警告
- ionic-framework - ionic3 pro包android:应用启动慢
- jmeter - Jmeter JMS 发布者问题
- npm - NPM:使用 package.json 卸载包
- python - Python:如何删除文本语料库中的标点符号,但不删除特殊单词中的标点符号(例如 c++、c#、.net 等)
- python - Python - 如何通过重定向获取最终 URL 和数据