I'm struggling to retrieve all the data from my RTD and store it in an array for iteration. The code below is returning 'undefined'. What could be the issue?
export class AppComponent {
cuisines$: Observable<any[]>;
cuisines: any[];
constructor(private db: AngularFireDatabase) {
this.cuisines$ = db.list('/cuisines').valueChanges();
this.cuisines$.subscribe(x => this.cuisines = x);
console.log(this.cuisines);
}
}
UPDATE: Transitioning to Cloud Firestore has successfully returned my array. Cloud Firestore seems like a promising choice!
export class AppComponent {
items: any[];
items$: Observable<any[]>;
constructor(private db: AngularFirestore) {
this.items$ = db.collection('items').valueChanges();
this.items$.subscribe(x => {
this.items = x;
console.log(this.items);
});
}
}