Issue
so I'm working on my ionic4 app and got an error on the auth in the try-catch block. I have tried installing the firebase package and adding the auth import but nothing seems to be working. What could be the problem?
import { Injectable } from '@angular/core';
import { AngularFireAuth } from '@angular/fire/auth';
import { Auth } from 'firebase';
@Injectable({
providedIn: 'root'
})
export class FirebaseAuthService {
auth: any[];
constructor(private angularFireAuth: AngularFireAuth) { }
async registerWithEmailPassword(email, password) {
try {
const result = await this.angularFireAuth.auth.createUserWithEmailAndPassword(email, password);
await this.angularFireAuth.auth.currentUser.sendEmailVerification();
return result;
} catch (error) {
throw new Error(error);
}
}
}
Solution
With the latest AngularFireAuth, you do not need to specify .auth anymore.
you can directly access angularFireAuth.currentUser to get the user information.
Answered By - Joko Supriyanto
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.