Issue
I got this error:
Type 'Observable<unknown[]>' is not assignable to type 'Observable<User[]>'.
I'm trying to fetch data from firestore.
I use Observable for the first time (I watch some videos about observable, but here I can't use why I do not understand). Can you help me?
by the way, user is this:
export interface User {
email: string;
uid: string;
}
my codes here:
usersCollection: AngularFirestoreCollection<User>;
users: Observable<User[]>;
constructor(public auth: AngularFireAuth, public db: AngularFirestore) {
**this.users(problem here)** = this.db.collection("users").valueChanges();
}
Solution
You can fix it by passing the User
type as a generic parameter to the collection
like the following:
this.users = this.db.collection<User>("users").valueChanges();
This will return Observable<User[]>
from the valueChanges
.
Answered By - Amer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.