0

I am developing an application in expo react native, I am facing an error since a week ago, I make api calls to any public or test api and the request passes normal, but when I try to make a call to our working api it shows the error of [AxiosError: Network Error], this only happens in Android but in IOS it works correctly, the data being sent is FormData. I'm using the latest version of Axios and React Native Doing debug, it seems that the call doesn't even go out or reach the api, we tried to open more ports from the API but it doesn't seem to work at all.

I tried to downgrade the axios version and trying to make the call on fetch but happens the same, on fetch appears the same "Network Error" I tried to run the app on a physical phone and even tried to run it after i built the APK

I FOUND A SOLUTION:

https://github.com/axios/axios/issues/4406#issuecomment-1058701729

I changed the code to this form and the request came out without any problem.

const formData = new FormData();
...
const response = await networking.post('/URL', formData, {
  headers: {
    'Content-Type': 'multipart/form-data',
  },
  transformRequest: (data) => {
    return data; // thats enough
  },
});
  • You should check this; https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted?rq=2 – Güray Jul 04 '23 at 23:19
  • There's some typo errors(misspelling, missing word),, but it isn't that big of an issue I think – rminaj Jul 05 '23 at 02:00

1 Answers1

0

I commented on this some time ago and hope it works for you. Try this solution: https://stackoverflow.com/a/59588664/12369564

enter image description here

Esteban Vega
  • 741
  • 6
  • 4