I am trying to fetch the firestore data and then store it in a variable
async function getchildContent(Parent, Message) {
let count = 0;
var db = firebase.firestore();
var output = db.collection("rooms").doc(Parent).collection("messages").where("ParentId", "==", Message).get().then(function (querySnapshot) {
querySnapshot.forEach(function (doc) {
})
});
return output;
}
This function i am calling as
var dataAll ={};
getchildContent(PDocId, doc.id).then(result=>{
dataAll = result;
});
console.log(dataAll);
If i assign it as
var output = getchildContent(PDocId, doc.id);
Then the result will br promise {pending}
But I am getting an empty array output, How to resolve this?
return db.collection("rooms").d......