How to access a typescript object?

1

I'm trying to access a database in 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 ghFinancas document 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 not able to access the elements of this object to play for my HTML.

Thanks for any help in advance

    
asked by anonymous 06.06.2018 / 16:12

0 answers