Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

197
Views
Why does 'formData' not work in 'axios 0.26.1' in react native Android emulator?

I have use expo-image-picker and axios 0.26.1. formData in axios version 0.26.1 isn't work. when using formData, data is not sent to the api

enter image description here

downgrade axios to version 0.24.0 but I get this error when sending formData in Android emulator.

Error: Network Error

formData:

enter image description here

export const sendRequest = (url, response, method, formData) => {
  return axios({
    url,
    method,
    data: method !== "get" ? formData : null,
    headers: {
      Authorization: `Bearer ${response.data.access}`,
      transformRequest: (data, headers) => {
        return formData;
      },
    },
  });

const formData = new FormData();
const imageUri = image.value.uri;
const newImageUri = "file:///" + imageUri.split("file:/").join("");

formData.append("photo", {
  uri: newImageUri,
  type: mime.getType(newImageUri),
  name: newImageUri.split("/").pop(),
});

data.append("title", title);

can you help me please?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This bug has been posted on Axios GitHub issues and apparently it is present since 0.25.0. I had to roll back to version 0.24.0 to make it work. However, this issue has been closed with the following solutions.

Method 1:

const formData = new FormData();
const response = await axios.post('/URL', formData, {
   headers: {
   ...formData.getHeaders()
   }
});

Method 2:

axios.post(url, formData, {
  headers: { 'Content-Type': 'multipart/form-data' },
  transformRequest: formData => formData,
})

You can check the issue here

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!