大约 4 天前,我开始使用 Firebase。虽然我没有保持一致。我想在数据库中创建一个用户,尽管用户已成功创建。创建用户后,假设返回头像页面,此阶段失败。
作为这个领域的初学者,我想知道我应该做对什么。
adduser(newuser) {
var promise = new Promise((resolve, reject)=> {
this.afireauth.auth.createUserWithEmailAndPassword(newuser.email, newuser.password).then(()=> {
this.afireauth.auth.currentUser.updateProfile({
displayName: newuser.displayName,
photoURL: this.mydefaultprofilepic.defaultProfileImage
}).then(()=> {
this.firedata.child(this.afireauth.auth.currentUser.uid).set({
displayName: newuser.displayName,
photoURL: this.mydefaultprofilepic.defaultProfileImage
}).then(()=> {
resolve({success: true})
}).catch((error)=> {
reject(error);
})
}).catch((error)=> {
reject(error);
})
}).catch((error)=> {
reject(error);
})
})
return promise;
}
这是我得到的错误
ERROR Error: Uncaught (in promise): Error: Reference.set failed: First argument contains undefined in property 'chatusers.AbdvZoGgqwNJcPfOpPKLqmCT1T12.photoURL'
Error: Reference.set failed: First argument contains undefined in property 'chatusers.AbdvZoGgqwNJcPfOpPKLqmCT1T12.photoURL'
at Object.exports.validateFirebaseData (vendor.js:38911)
at vendor.js:38957
at Object.exports.forEach (vendor.js:76671)
at Object.exports.validateFirebaseData (vendor.js:38940)
at Object.exports.validateFirebaseDataArg (vendor.js:38899)
at Reference.set (vendor.js:63235)
at main.js:45
at e.g (vendor.js:76794)
at Eb (vendor.js:76797)
at Ab (vendor.js:76797)
at Object.exports.validateFirebaseData (vendor.js:38911)
at vendor.js:38957
at Object.exports.forEach (vendor.js:76671)
at Object.exports.validateFirebaseData (vendor.js:38940)
at Object.exports.validateFirebaseDataArg (vendor.js:38899)
at Reference.set (vendor.js:63235)
at main.js:45
at e.g (vendor.js:76794)
at Eb (vendor.js:76797)
at Ab (vendor.js:76797)
at c (polyfills.js:3)
at c (polyfills.js:3)
at polyfills.js:3
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (vendor.js:5114)
at t.invokeTask (polyfills.js:3)
at r.runTask (polyfills.js:3)
at o (polyfills.js:3)
at e.invokeTask [as invoke] (polyfills.js:3)
at p (polyfills.js:2)
defaultErrorLogger @ vendor.js:1822
我已经搜索了关于 SO 的其他类似问题,但他们没有直接解决这种情况