I currently working on a mobile application using the front-end framework Ionic and angularjs with typescript and for the backend I'm using firebase. My problem is that when I make a call to my firebase nosql database I can't get it my items into an typescript array in order to get the data to the screen because when I call the variable containing the values it comes as undefined. Here is my code:
getSingleDatabase(){
this.collectionReference=this.db.collection('posts');
this.collectionReference.get()
.then(snapshot =>{
snapshot.forEach(doc => {
this.firstGet.push(doc.data());
});
})
.catch(err =>{
console.log(err);
});
return this.firstGet;
}