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 request throwing "Network Request Failed" error across host REST End point Android #5222
Comments
Hey sachin1, thanks for reporting this issue! React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.
|
Hi Team, Issue has been resolved on android. It was problem with body and headers of get/post request in fetch call. For ios, it was working and no changes required. |
I also get the same error, when I run another local server(based on JavaEE) to provide data. Finally, I replace the "localhost"(or "127.0.0.1") with my IP address, such as "192.168.56.1". It is resolved. |
yes after changing localhost to IP Adress of system the problem got solved @dongrenguang |
Where do I have to change the IP? |
I have this exact issue, even when using the examples from: https://facebook.github.io/react-native/docs/network.html There is no localhost involved in my request addresses, so how would changing the IP help and where do I change it? Never mind, it's answered: Thanks to PierBover's profile I found this post: So iOS doesn't support http requests out of the box, only https. See: https://facebook.github.io/react-native/docs/running-on-device-ios.html#app-transport-security |
@Joralf Hi, what about Android ? |
@Clcll it's the same for android, add the ip instead localhost |
I have the same issue: I tried the POST request from postman (a tool to send post request) and it worked...
Does someone have an idea ? |
I found my mistake ... |
Using it with feathersjswe can use either fetch() i.e from react native networking or we can use app.service() of feathersjs Code for both way is written down:1> Using Fetch() -React Native fetch('http://192.168.1.xxx:3030/sms').then((response) => console.log(response)); 2> using App.service() - Feathersjs app.service('sms').find({}).then(function(response){ you need to use these two lines too const host = 'http://192.168.1.xxx:3030'; Its working fine with IOS and Android in my case .I have used url ie IP Address of other system where feathersjs server is running . |
I'm not running against local host (using a real API) and I'm still getting this error. Cannot change to IP because the API is dynamic. |
@voidstarfire enter the server url along with port it is running on . |
Due to the nature of the environments that are setup we don't know the server ports. We get the address only as it's a distributed hub (millions of users). |
@voidstarfire if you don't know the port then you can try for default port depending on the backend server language.(node > 3030/3000 ) .you can google this out . |
Hello, I got exacte same issue today, does anyone have a solution ? |
@trinhvanhuy are you sure your mobile is connected to the same network that your phone ? |
Hi, pls give some example for JSON parsing(POST) in React Native Android |
your post save me @qlerebours. actually forgot connecting android to the same network |
I had the same issue and I used localtunnel to work around it https://localtunnel.github.io/www/ |
I am having the same issues with POST on android devices using react native 'fetch'. GET requests work fine (ios and android) but POST returns 'Network request failed'. My url is 'https://PREFIX.URL.com', which is public, not localhost. The ip address is dynamically assigned by a load-balancer (but I have tried with the current ip address and port as mentioned above and it still fails). I am at a loss trying to find the solution, any new ideas?? |
Wanted to update in case my problem can help others. My error was specific to Android and more specifically, the intermediate certificate on the server. During the OAuth process in our app, we use a WebView for the user to authenticate. After login, we request a valid token. The android browser is stricter (or not as efficient at finding cert chains) than ios (and chrome for that matter) and was not allowing the POST request to be sent to the server. After installing the intermediate cert correctly, all is well. Here is a convenient site to check your cert (enter your site at the top): https://www.digicert.com/help/ Hope this helps someone else! |
i try to get tinder profile using tinder api doc but i can not access this because i got this error {"status":401,"error":""} |
@masylum that's the solution! |
@dongrenguang how to change the ip, my project rn version is 0.51, https request is always failed, 'TypeError: network request failed'. how to resovle the problem , anyone help me ? |
Above is my code but i still run into the issue while calling a api running on local server |
Hi,
I have written react native app which is working fine for IOS but while testing on google android simulator, it throws an error: "Network Request Failed".
Url address: http://192.x.x.x:8000/api/data.
Both Emulator and REST Server are running on different host, so communication is across host.
REST communication across host working fine for ios.
I have checked network connectivity in emulator and able to surf internet from browser.
Please provide any inputs to fix this
The text was updated successfully, but these errors were encountered: