firebase的updateProfile是否在Promise中返回用户

时间:2018-01-12 21:19:48

标签: javascript firebase

我试图做类似的事情:

firebase.auth().currentUser.updateProfile({displayName: 'test'})
  .then(user => {
   console.log(user);
  })
  .catch(err => {
   console.log(err);
  }

但是控制台用户什么都没有显示。它不会在承诺中返回任何内容吗?

1 个答案:

答案 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.
});