I am trying to iterate through an array of objects in react native but some reason I can't do it. This is what my array looks like. here is the array
When I try to map through this array with arr.map((item,key) => console.log(item.id))
nothing happens in debugger.
Any help?
Edit2: This is the full function.
getPhotos = async () => {
var firebaseStorageRef = await firebase.storage().ref();
const photos = [];
const documentSnapshot = await firestore()
.collection('pictures')
.doc(this.props.route.params.tc)
.collection('photos')
.get()
.then(function (querySnapshot) {
querySnapshot.forEach(function (doc) {
const imageRef = firebaseStorageRef.child(doc.data().path);
imageRef.getDownloadURL().then(data => photos.push(
{id: doc.id, link: data}
))
})
});
console.log(photos); //This shows the array in the debugger
photos.map((item,key) => console.log(item)); //Nothing executes in this line
}
imageRef.getDownloadURL...
line of code you can runconsole.log(photos)
and you get a result ofphotos
and if you dophotos.map((item,key) => console.log(item.id))
after that console log and you get nothing?