Jeremia777
New Coder
Hello,
i can't access the properties of the array,because it is empty, the console says to me "This value was evaluated upon first expanding".
Here is the code
i can't access the properties of the array,because it is empty, the console says to me "This value was evaluated upon first expanding".
Here is the code
JavaScript:
var querySnapshot = await getDocs(collection(db, "messages"));
var arraymessages = [];
querySnapshot.forEach(async (doc) => {
if(doc.id.split(":")[0] == nicknameUser || doc.id.split(":")[1] == nicknameUser){
var messagesField = await getDocs(collection(db, "messages/"+doc.id+"/messages"));
var messagesa = [];
messagesField.forEach((messageDoc) => {
messagesa.push(messageDoc.data().message);
})
var messages = {'sender': doc.id.replace(/:/g, "").replace(nicknameUser, ""), 'message' : messagesa};
arraymessages.push( messages);
}
else{
}
});
console.log(arraymessages)