I started with Firebase about 4 days ago. Though I have not being consistent. I want to create a user in the db, though the user was created successfully. After the user creation, it is suppose to return the profile picture page, it fails at this stage.
Being a beginner in this field, I wish to know what I'm to do right.
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;
}
This is the error I'm getting
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
I have searched other similar questions on SO but they didn't directly address this situation