我正在尝试调用 fetch 请求并且它在 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