我试图做类似的事情:
firebase.auth().currentUser.updateProfile({displayName: 'test'})
.then(user => {
console.log(user);
})
.catch(err => {
console.log(err);
}
但是控制台用户什么都没有显示。它不会在承诺中返回任何内容吗?
答案 0 :(得分:4)
根据Firebase documentation on updateProfile
:
updateProfile
返回非空的firebase.Promise包含void这方面的一个例子:
// Updates the user attributes: user.updateProfile({ displayName: "Jane Q. User", photoURL: "https://example.com/jane-q-user/profile.jpg" }).then(function() { // Profile updated successfully! // "Jane Q. User" var displayName = user.displayName; // "https://example.com/jane-q-user/profile.jpg" var photoURL = user.photoURL; }, function(error) { // An error happened. }); // Passing a null value will delete the current attribute's value, but not // passing a property won't change the current attribute's value: // Let's say we're using the same user than before, after the update. user.updateProfile({photoURL: null}).then(function() { // Profile updated successfully! // "Jane Q. User", hasn't changed. var displayName = user.displayName; // Now, this is null. var photoURL = user.photoURL; }, function(error) { // An error happened. });