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

111
Vistas
Error consuming array of objects in React

When I try to consume this response in the frontend like customers.NombreCompletoI don't get any data and I can not figure out what am I doing wrong when parsing this; I need the response to be as below.

Code in ReactJS:

const fetchUsers = () => {
  var users = [];
  axios.get(`https://localhost:7150/api/employees`).then(response => {
    users = response.data;  // this is an array of users.
  });

  return users;
}
export const customers = fetchUsers();

Data from API when consuming with axis.get():

[
    {
        "NombreCompleto": "Jan Murillo Barquero",
        "Cedula": "0987654321",
        "Telefono": "23213433",
        "Direccion": "Alajuela, Alajuela"
    },
    {
        "NombreCompleto": "Gabriel Zuniga Orozco",
        "Cedula": "2365123132",
        "Telefono": "35435344",
        "Direccion": "Heredia, Heredia"
    }
]

How I needed, because using this data just like this it does works:

const customers = [
  {
    "NombreCompleto": "Jan Murillo Barquero",
    "Cedula": "0987654321",
    "Telefono": "23213433",
    "Direccion": "Alajuela, Alajuela",
    "avatarUrl": "/static/images/avatars/avatar_3.png"
  },
  {
    "NombreCompleto": "Gabriel Zuniga Orozco",
    "Cedula": "2365123132",
    "Telefono": "35435344",
    "Direccion": "Heredia, Heredia",
    "avatarUrl": "/static/images/avatars/avatar_3.png"
  }
]
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