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

113
Views
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
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!