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

120
Vistas
axios successful request but data is undefined

I'm uploading multiple files separately using axios.

This is the request(all the following code is inside an async function):

const proms = files.map(file => {
  let formData = new FormData();
  formData.append("file", file);
  return axios.post(`/upload/${userId}`, formData)
});

proms will be an array of promises so I proceed to Promise.all it:

const res = await Promise.all(proms)

If I do console.log(res) it shows a successfull response from server as you can see here:

Array(3) [ {…}, {…}, {…} ]​
  0: Object { data: {…}, status: 200, statusText: "OK", … }​​
    config: Object { timeout: 0, xsrfCookieName: "XSRF-TOKEN", xsrfHeaderName: "X-XSRF-TOKEN", … }​​
    data: Object { fieldname: "file", originalname: "612_photo.jpg", encoding: "7bit", … }​​​
    destination: ********************​​****
    encoding: "7bit"​​​
    fieldname: "file"​​​
    filename: "/1648309550808-586868206.jpeg"​​​
    mimetype: "image/jpeg"​​​
    originalname: "612_photo.jpg"​​​
    path: ********************​​****
    size: 43267​​​
    <prototype>: Object { … }​​
    headers: Object { "content-length": "395", "content-type": "application/json; charset=utf-8" }​​
    request: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, … }​​
    status: 200​​
    statusText: "OK"​​
    <prototype>: Object { … }​
  1: Object { data: {…}, status: 200, statusText: "OK", … }​
  2: Object { data: {…}, status: 200, statusText: "OK", … }​
  length: 3​
  <prototype>: Array []

But then when I do console.log(res.data) it is undefined. What is happening here?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

your response(res) is An array so you cant access res.data ,try :

res.forEach(item=>{console.log(item.data)})
about 4 years ago · Juan Pablo Isaza Denunciar
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