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

128
Vistas
Problem mapping over data from API as its just an object not an array of objects in React

If I have this data structure coming from an api:

{
  "value": 0,
  "time": [
    "2021-10-15"
  ],
  "innerArray": [
    {
      "name": "string",
      "Value": [
        0
      ]
    }
  ]
}

I am trying to access the element by:

let dataLoop = data // object from api

then I am doing:

   function Loop() {
        dataLoop.map((inner: any) => {
            console.log('series =', inner.innerArray);
        })
    };

But I am getting TypeError: dataLoop.map is not a function

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

0

It is because

{
  "value": 0,
  "time": [
    "2021-10-15"
  ],
  "innerArray": [
    {
      "name": "string",
      "Value": [
        0
      ]
    }
  ]
}

is an object, you can map only on Array type elements.

innerArray is an element on which you can .map like this:

    dataLoop.innerArray.map((inner: any) => {
        console.log('series =', inner);
    })

to be able to map through an object you have to use Object like:

Object.entries(data).map(([key,value])=>{
  console.log(key,value)
})

for example, so output would be like :

enter image description here

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