无法使用Angular 13在Firebase中更新数据
这是我第一次使用Firebase,因此仍在尝试掌握东西,但我似乎无法写入实时数据库。我已将规则更新为“写”。
import { Injectable } from '@angular/core';
import { AngularFireDatabase } from '@angular/fire/compat/database';
@Injectable({
providedIn: 'root'
})
export class UserService {
constructor(private db : AngularFireDatabase) { }
save (user: firebase.default.User) {
this.db.object('/users/'+ user.uid).update({
name: user.displayName,
email: user.email
});
}
}
我正在使用Google身份验证,并且用户本身是在“身份验证”选项卡下创建的。此外,我还监视了Chrome中的“网络”选项卡,当调用保存功能时,没有任何数据库请求,这使我假设数据库已被错误地设置。
Its my first time using Firebase so still trying to get the hang of things but I can't seem to write to the RealTime database. I have updated the rules to 'write'.
import { Injectable } from '@angular/core';
import { AngularFireDatabase } from '@angular/fire/compat/database';
@Injectable({
providedIn: 'root'
})
export class UserService {
constructor(private db : AngularFireDatabase) { }
save (user: firebase.default.User) {
this.db.object('/users/'+ user.uid).update({
name: user.displayName,
email: user.email
});
}
}
I am using google authentication and the User itself is created under the Authentication tab. Additionally I also monitored the network tab in chrome and there is no request to any database when the save function is called which leads me to assume that the database has been incorrectly set up .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
休息一下,重新启动了我的PC,打开了VS代码并为该项目服务,并以某种方式开始工作。有时,良好的旧“关闭,打开”会产生奇迹。
Took a break, restarted my pc, opened VS code and served the project and somehow it started working. Sometimes the good old "switch off, switch on" does wonders.