React Native, getting network error while posting FormData with Axios

Hakan Alp

I am trying to send an audio/image by creating FormData.

My current versions are: "react-native": "0.59.10", "axios": "^0.19.2", "react": "16.8.3". And I am testing my app on my android device

and getting "network error" every single time while sending FormData.

here is my way of creating and sending post;

  let new_options = {
    headers: {
      'Content-Type': 'multipart/form-data',
      'Authorization': myAuthorization
    }
  };
  const content = new FormData();
  content.append('file', {
    uri: 'file://' + attachment.path,
    name: 'test',
    type:  attachment.type
  });
  content.append('ReportId', report_id);
  content.append('MimeType', attachment.type);
  
  try {
    let res = await axios.post(myUrl, content, new_options);
  }catch(err){
    console.warn(err);
  }

I already tried things like updating FLIPPER_VERSION or editing ReactNativeFlipper.java but none of this things exists in my project since I am using older version of react-native. I also tried to delete the debug folder.

Hakan Alp

Figured it out, problem was caused by wrong MimeTypes.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Network error with axios and react native

Network Error on formdata POST request React Native

request formData to API, gets “Network Error” in axios while uploading image

Issue Error Network with Axios on React-native

Network error in use of axios and fetch in react native

axios giving [AxiosError: Network Error] in react native

Network error on posting a request using axios

Getting Error while building React Native project

Getting error while creating react native app

Getting error while creating react native app

React: Axios Network Error

getting Network Error when calling axios get request in react js

React native axios post request network error on Android physical device

React Native Axios upload image return Network Error on Android

Network Error from React Native axios call to Node.js

axios showing Network request failed error in react native

.NET Core Web API posting formdata and getting 400 error

React-native, Firebase network error while trying to log in

Unknown "Network Error" with axios in React

I am getting error while fetching data in react-native

Getting an error for React Native while Building Android App

Getting error while implementing Tab Navigator in React Native

react native, getting error while generating signed apk

Getting error while entering data via AsyncStorage React-native

Getting an undefined object error in react native while using state?

What is the correct way to use Axios Create With Multipart and FormData in React Native

Error: Network Error using axios in React Native, issue in only in iOS and Android

getting error while posting on facebook using javascript sdk

React Native Fetch() with FormData() HTTP TypeError: Network request failed