In my Angular app, I'm getting this error when I try to compile:
Type
'Observable<Promise<void>>'
is not assignable to type'Observable<AuthResponseData>'
. Type 'Promise' is missing the following properties from type 'AuthResponseData': kind, idToken, email, refreshToken, and 2 more
Here is the AuthResponseData
interface:
export interface AuthResponseData {
kind: string;
idToken: string;
email: string;
refreshToken: string;
localId: string;
expiresIn: string;
registered?: boolean;
}
Here is the login() method:
login() {
let authObs: Observable<AuthResponseData>;
authObs = this.authService.login(this.email, this.password);
authObs.subscribe(
resData => {
console.log('Response Data:', resData);
this.router.navigateByUrl('/home');
},
errRes => {
console.log('Error Response:', errRes);
});
}
And here is AuthService.login()
:
login(email: string, password: string) {
return of(firebase.auth().signInWithEmailAndPassword(email, password)
.then((user) => {
console.log('Service User Value', user);
}).catch((err) => {
console.log('Service Error', err);
}));
}
Can someone please tell me what changes I need to make so that I'm assigning the correct type in the Observable?