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

326
Views
Getting error while sending image to an API using formData - React and Axios

I am using formdata to send images to the server but when I use the append function, it does not add anything to formdata that I have declared and I keep getting a 400 error.

const fileSelectHandler = (e) => {
    e.preventDefault();
    setFile(e.target.files[0]);

    let image = file;
    let formData = new FormData();

    formData.append("image", image);
    console.log(formData);
    
    Axios.post(imgUrl, formData, config)
      .then((response) => console.log("Response: " + response))
      .catch((err) => console.log("error: " + err));
  };

and the input:

<input
  type="file"
  className="form-control"
  onChange={fileSelectHandler}
/>
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!