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

Tay*_*tin 0 javascript firebase

我正在尝试做类似的事情:

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

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

zb2*_*b22 5

根据Firebase文档updateProfile

updateProfile 返回非null的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.
});
Run Code Online (Sandbox Code Playgroud)