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