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

336
Vistas
Pushing element adds element to the list but doesn't increase in length but shows up in console.log, but doesn't let me print by index

My code:

useEffect(() => {
    var tempList = []
    axios.get("#url")
    .then(res =>{
            res.data.Items.map((eachARN)=>{
                axios.get("#url" + res.uuid.S)
                    .then(res =>{
                      tempList.push(res.data.Item.uuid.S)
                    })
                    .catch(err =>{
                        console.log(err);
                    })
            })
            console.log("templist length: "+tempList.length)
            console.log(tempList)
            setposts(tempList)
     })
    .catch(err =>{
      console.log(err);
    })
  }, [])

The console log shows: [enter image description here][1]

So it is showing me all the elements I want to push but somehow they are not in the list they are being printed as in the list but the length is 0 [1]: https://i.stack.imgur.com/p0pjR.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