Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

328
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda