I encountered a "Cyclic Object Value" Error while working on an Angular Project with AngularFire. As a beginner with Firebase, I haven't been able to find a straightforward solution to this issue.
The error arises when I query a collection in my Firestore DB and then attempt to query another collection using the Document ID from the initial query.
Below is the relevant code snippet:
foo.service.ts:
async checkOrgas() {
let orga: any;
const user = await this.afAuth.currentUser;
const results = this.db
.collection('orgas', (ref) => {
return ref.where('createdBy', '==', user.uid);
})
.valueChanges({ idField: 'orgaID' })
.pipe(take(1));
return results;
}
async getOrgaBankings(orgaID: string) {
const results = this.db.collection('bankings', (ref) => {
return ref.where('orga', '==', orgaID);
}).valueChanges({ idField: 'bankingID' });
return results;
}
foo.component.ts:
async getOrga() {
const orgas = await this.orgaService.checkOrgas();
this.orgasSubscription = orgas.subscribe((val) => {
this.orga = val[0];
val.length > 0 ? (this.memberOfOrga = true) : (this.memberOfOrga = false);
}
async loadOrgaBankingInfo() {
this.orgaBanking = this.orgaService.getOrgaBankings(this.orga.orgaID);
}
I received the following Error message in Firefox:
ERROR TypeError: "cyclic object value"
Although I have a basic understanding of what this error indicates, I am struggling to find a proper resolution for it.