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

181
Views
Axios wont send image over form in React-Native

I have been chasing this bug for several days and finally found that it is axios. Why does fetch work to upload an image from React-Native to Django REST here:

export const uploadBusinessImage = createAsyncThunk(
  "business/uploadBusinessImage",
  async (imgPath, { rejectWithValue }) => {
    var formData = new FormData();
    formData.append("image", {
      uri: imgPath,
      name: "myfoto.jpg",
      type: "image/jpg",
    });
    const url = "http://10.0.0.241/api/upload/";
    fetch(url, {
      method: "POST",
      headers: {
        "Accept": "application/json",
        "Content-Type": "multipart/form-data",
      },
      body: formData,
    })
  }
);

but axios doesn't work here:

export const uploadBusinessImage = createAsyncThunk(
  "business/uploadBusinessImage",
  async (imgPath, { rejectWithValue }) => {
    try {
      var formData = new FormData();
      formData.append("image", {
        uri: imgPath,
        name: "myfoto.jpg",
        type: "image/jpg",
      });
      const response = await axiosInstance({
        method: "post",
        url: "/api/upload/",
        data: formData,
        headers: { 
          "Accept": "application/json",
          "Content-Type": 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW'
        },
      });
      console.log(response.data);
      return response.data;
    } catch (err) {
      console.log(err.response.data);
      return rejectWithValue(err.response.data);
    }
  }
);

It creates the object in the database as image: null

about 4 years ago · Juan Pablo Isaza
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!