【发布时间】:2021-09-16 23:20:00
【问题描述】:
我正在尝试使用 Angular 和 Firebase 身份验证构建应用。
auth.service.ts
async loginWithEmailAndPassword(email: string, password: string) {
try {
await this.auth.signInWithEmailAndPassword(email, password);
} catch(error) {
throw error;
}
}
login-page.component
async loginWithEmailAndPassword() {
if (this.form.status !== 'INVALID') {
try {
await this.authService.loginWithEmailAndPassword(this.email?.value, this.password?.value)
} catch(error) {
console.log('Hello, this is my custom error');
}
}
}
这是预期的行为吗?我认为 try...catch 可以防止这种情况发生。
我什至尝试删除异步等待语法,但没有任何改变。
【问题讨论】:
标签: angular error-handling firebase-authentication