Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

112
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda