-
Notifications
You must be signed in to change notification settings - Fork 24.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fetch not working for HTTP requests on Android #24408
Comments
Hey, I've had a similar problem, please make sure your request URL is HTTPS not HTTP as Android from new versions doesn't allow HTTP |
Unfortunately no...Best bet is debug js remotely option, moreover fetch related errors are not accurate at all for example recently I got a network request failure, then after hrs of self debugging I fixed my form data object |
Try using this one. It worked for me. Add the codes in your main AndroidManifest.xml :
|
Thanks @alexPimentel. It works for me |
Thanks @alexPimentel for me it works even without tools:targetAPI="28". |
me too |
Just had this issue and want to comment that this works |
further to @alexPimentel's post: "Indicates whether the app intends to use cleartext network traffic, such as cleartext HTTP. The default value for apps that target API level 27 or lower is "true". Apps that target API level 28 or higher default to "false"." explains why this is a "sneaky regression". |
I am using expo and i don't have android and ios directory. How can i fix this issue.? |
I have same problem in my case everything resolve when I access my emulalator to network. I resolve from below. https://stackoverflow.com/questions/42736038/android-emulator-not-able-to-access-the-internet |
this works for me
|
I love you, man! |
https://github.com/facebook/react-native/issues/24408#issuecomment-490368508
It's Work ,,, thank you,,, |
I am facing the same issue in android release apk. React native version is 61.5. Tried with android:usesCleartextTraffic="true"( tried with fetch and axios ,still not working). Also tried with http and https also, still no luck. |
@cjahfar1 Are you solve it? |
Yes,. Actually "android:usesCleartextTraffic="true"" fixed the issue. There were another error which was blocking the api calls and the error was swallowed since this error happens in saga function. Sorry for not updating here. |
I add
But it's working fine in my Physical device |
Status code 400 means, bad data. Double check the payload format. You are getting response 400, that means, API call is getting initiated. |
what is the error in saga function, and how to fix it man, plz help |
thanks. It works |
Not for me |
Hi, but what was blocking the API calls? |
🐛 Bug Report
When using fetch on
http
endpoints, the request raises a Network Request Fail error.If works fine on
https
endpoints.To Reproduce
use
fetch
with any http url.Expected Behavior
The fetch function returns without throwing a Network Request Fail
Code Example
fetch(any-http-url)
Environment
The text was updated successfully, but these errors were encountered: