【发布时间】:2021-02-12 13:08:11
【问题描述】:
我是新的 firebase 数据库,我尝试在注册时将 UID 更新为实时数据库,但出现这样的错误
错误:Reference.update 失败:第一个参数在属性“users.UID.email”中包含未定义
auth.service.ts
import ...
...
export class AuthService {
...
async emailSignUp(email: string, password: string) {
try {
const user = await this.afAuth.auth.createUserWithEmailAndPassword(email, password);
console.log('user ', user);
this.authState = user;
console.log('authState ', this.authState);
this.updateUserData();
this.router.navigate(['/']);
} catch (error) {
return console.log(error);
}
}
get currentUserId(): string {
console.log('currentId ', this.authenticated, ' ', this.authState.user.uid);
return this.authenticated ? this.authState.user.uid : '';
}
private updateUserData(): void {
const path = `users/${this.currentUserId}`; // Endpoint on firebase
const userRef: AngularFireObject<any> = this.db.object(path);
const data = {
email: this.authState.email,
name: this.authState.displayName
};
userRef.update(data)
.catch(error => console.log(error));
}
}
有人可以帮帮我吗? 如果需要更多的 sn-ps,请告诉我。提前致谢。
【问题讨论】:
标签: angular typescript firebase firebase-realtime-database