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

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