1
I’m trying to access a database on firestore
with this getAlldocuments
:
getAllDocuments(collection: string): Promise<any> {
return new Promise((resolve, reject) => {
this.db.collection(collection)
.get()
.then((querySnapshot) => {
let arr = [];
querySnapshot.forEach(function (doc) {
var obj = JSON.parse(JSON.stringify(doc.data()));
obj.$key = doc.id
console.log(obj)
arr.push(obj);
});
if (arr.length > 0) {
console.log("Document data:", arr);
resolve(arr);
} else {
console.log("No such document!");
resolve(null);
}
})
.catch((error: any) => {
reject(error);
});
});
}
The original data is in the firestore document ghFinancas in the following format:
data: string
desc: string
valor: number
tipo: string
My problem is that the result of getAllDocuments generates an object and I am unable to access the elements of this object to play for my HTML.
I appreciate any help in advance