[英]React Native Fetch Not Working on Android
fetch("http://httpbin.org/post")
.then(response => response.json())
.then(responseData => {})
.catch(error => {
Alert.alert("error:" + error);
});
I am trying to get fetches to work on Android. 我正在尝试获取内容以在Android上运行。 The sample code above get's called, however, it alerts "error:TypeError: Network request failed".
上面的示例代码被调用,但是,它警告“错误:TypeError:网络请求失败”。
I have the INTERNET permission set in my Android manifest file. 我在Android清单文件中设置了INTERNET权限。 Not really sure what else to do.
不太确定还要做什么。 Is there a way I can find out the reason for the error?
有没有办法找出错误的原因?
EDIT When debugging, status is 0, timeout is 0, response is null, responseURL is undefined, and responseType is blob. 编辑调试时,状态为0,超时为0,响应为null,responseURL未定义,responseType为blob。
http是您的问题...需要https
Adding this to Manifest file solved my issue in Android 9 将此添加到清单文件中解决了我在Android 9中的问题
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application android:usesCleartextTraffic="true" tools:targetApi="28" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.