-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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
Axios doesn't work with Android (emulator) raising a Network Error #973
Comments
I am getting this error as well with Android in React Native. It works fine with iOS. |
I am also getting this error with Android in React Native. |
Is axios really not supported in Android? 😨 |
Same issue, does anyone solve it? |
will work in iOS but will not work in Android. HTTPS doesn't support in android. |
mark |
can any one help https://stackoverflow.com/questions/46307932/network-error-in-axios-post-request-react-native please ? |
Same Issue under different conditions. Axios throwing Network Error, but only on iOS Simulator. Works Fine on android (Tested on actual Device). Using AWS server with http not https. Help Please |
GET is not able to use axios.interceptors.request.use((config) => {
if (config.method !== 'get') {
config.data = qs.stringify(config.data) // fix Rails i18n error
}
if (typeof config.params === 'undefined') {
config.params = {}
}
return AppSettingService.getAppSetting()
.then((appSetting) => {
config.params.locale = appSetting.locale
config.params.currency = appSetting.currency
return ProfileService.getCurrentUser()
.then((currentUser) => {
if (currentUser) {
config.headers.common.Authorization = currentUser.token
}
return config
})
})
}) I hava similar issues, but I fixed this Network Error with omiting |
@hzburki I had got the same issue as you, but I found that, on android emulator, the timeout for a network request seems to be 2 or 3 minutes. However, setting default timeout of Axios does not work on android emulator. |
Hey @hpb0412 ... I'm sorry its been a while since I posted this so I don't remember how I got past the issue. However looking at it now it seems I hadn't enabled App Transport Security for iPhone at the time, since it was working fine on Android. But this doesn't help you. It would help looking at the error log at backend where you're sending the GET request and trying the same request with Postman to make sure there is nothing wrong at the back-end code. |
it seem like a "fetch problem" i had met on React Native specific for Android 7.0. |
I am getting the same network error with a simple Get request `var instance = axios.create({
`▼Network Error
|
I had a similar problem and found a solution. My problem was related to my domain. Edit: According to http://ssllabs.com, both certificates are identical and are supposed to work on all last Android version. |
please help with this, it still doesn't work, I'm having the same problem |
@hsunami10 What is your domain? Do you have a repo with your app? |
@hsunami10 I worked around the issue by setting up an external staging server and pointing to that for testing with the emulator. |
Guys, I also struggling on this issue for quit while. But I figured out the issue of my axios post network createError on Android device now. The reason to axios Network Error is because the form data I passed to axios contains wrong type of data object I guess. I have include an image object(ImagePicker object from Expo) as a one of param of form data which not accept by axios I think. Axios might only receive string, float, int or image as param. image cannot pass as param, it is not an type of image, it is an react native object, I have removed it and include an image field as param by assign image.uri to value of param then it works. Hope this will help some of people who may encounter same problem as I was facing before. |
If you are trying to call localhost on android simulator created with AVD, replacing |
With case upload media process, i suggest all of you to use |
@VitaliiK91 do you mean the ADB settings in Genymotion. Where is localhost setting to replace? |
I'm having the same problem with a simple GET request to my Rest API hosted in heroku. On IOS emulator the same request works well.
|
I tried to use headers too, but not working too.
|
I am also having the same problem. This is only related to Android 7.0, for other Android versions, it works well. |
I'm having the same issue as well. I'm on the latest version of Android and I've tried sending a simple text over to my server but still receiving network error. Same thing goes for the get request |
I finally manage to fix the issue. Used my networks IP address and it works. eg http://:/api |
Got them |
this worked for me. I am using MAC |
similar issue here, everything works find with iOS, android just can't work! |
Same issue here. I am already using
After searching, this issue seems to happen only when I am updating a table in my DB. The strangest thing is that my update actually happened as programmed. There is just... No response. |
the same issue, it works well in ios,but get
modified local hosts file ? |
My GET request using Cordova comes back with
And I'm using Cordova 8.0.0. I've tried HTTPS & HTTP, I've tried different domains as well. |
What worked for me was instead of using https:// I used http:// for the Android emulator. For iOS http:// doesnt work while https:// does. |
This is not the solution if i have oonly one https domain. |
That worked for me.
My header:
|
I have a test application that its backend is done in Adonis (local) and the front react-native and axios, to show a get of an API, but in the emulated it presents the following error:
|
At least for me, which I have api running locally by "Adonis", I put the following address in my android emulator, which is different from the address used by the computer. /* Endereços para cada emulador/simulador: |
OMG, you've saved my time bro! |
Nothing worked. |
What is the error? |
Hello @helloitsm3, Just fixed this. Was experiencing same error as this issue title. |
I'm so disappointed when it worked. |
For anyone facing issues on Android 9, just add I read through all the answers above and just adding what worked for me. |
@yasirlateef this flag https://developer.android.com/guide/topics/manifest/application-element#usesCleartextTraffic |
is there anything to do on axios' end? |
There's nothing to do on Axios end. All you have to do is to use the ip address instead of localhost and it'll work |
This could be the problem |
Looks like the problem is related to some Android settings. If there is anything axios should have to improve, feel free to open an issue. |
@ghost Super correct, 200% Right |
|
Meu caso funcionou trocando o localhost pelo ip da maquina na chamada da api |
I had similar problem with my website hosted on AWS EC2 working fine in desktop browser, but it wasn't fetching data from the database through the API (hosted also there). I was trying to fetch it through Somebody here recommended to change localhost to the actual IP address of the server, even though that's working fine on desktop, and so I tried changing the URL to |
and : |
If you have the luxury of stepping up to a newer Android version I've done the following tests: I haven't tried newer versions (exept on a physical phone (Android 10)) where it also works. |
Could you please let me know how to do this in detail? |
I'n new with React Native, and I was playing around with components and http ajax request, and all went fine with iOs emulator, until I thought to test on Android emulator.
This is my Http class:
This is the error I'm getting from the post request, using login() function I created using axios.post()
NOTE:
I'm using the latest version of Axios ^0.16.2
My AndroidManifest.xml contains:
The text was updated successfully, but these errors were encountered: