Encountering an error during the compilation of my Angular app:
The error message states: Type 'Observable<Promise<void>>' is not compatible with type 'Observable<AuthResponseData>'. The issue lies in 'Promise' lacking properties such as kind, idToken, email, refreshToken, and more
Definition of interface AuthResponseData
:
export interface AuthResponseData {
kind: string;
idToken: string;
email: string;
refreshToken: string;
localId: string;
expiresIn: string;
registered?: boolean;
}
Code snippet for 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);
});
}
Implementation of 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);
}));
}
Seeking guidance on resolving the issue related to assigning the correct type in the Observable. Any suggestions?