ERROR FirebaseError: Expected type 'Query', but it was: a custom dh object

Discussão em 'Angular' iniciado por Shane Johnson, Fevereiro 20, 2025.

  1. When I try to subscribe to collectionData or docData, I always get this error "ERROR FirebaseError: Expected type 'Query', but it was: a custom dh object". The weird part is I have an app using Angular 15 and I do NOT have this issue there. This app is Angular 16, and I have it setup the same exact way. I'm not sure if the Angular version has anything to do with it.

    import { Firestore, collection, collectionData, query } from '@angular/fire/firestore';

    constructor(
    private firestore: Firestore
    ) { }

    getNotes(user: string) : Observable<Notes[]> {
    const collectionRef = collection(this.firestore, `notes/${user}/notes`)
    const q = query(collectionRef)
    var notes$ = collectionData(q, {idField: 'id'}) as Observable<Notes[]>
    notes$.subscribe(notes => {
    console.log(notes)
    })
    }


    If I use getDocs, with "then" instead of "subscribe", that seems to work. But that is just a one time call, and I want to listen for changes. I have looked all over the internet for an answer, but anything like this is usually because people are using two different libraries. I am definitely not. I hope someone can help!

    Continue reading...

Compartilhe esta Página