繁体   English   中英

user.getIdToken 不是 function

[英]user.getIdToken is not a function

export const editEmail = async (newEmail) => {
  await updateEmail(auth, newEmail);
}; // my code in firebase
    try {
      setLoading(true);
      console.log(newEmail);
      await editEmail(newEmail);
      Setmessage("update email berhasil");
    } catch (e) {
      console.log(e);
    }
    setLoading(false);
  };// my code handle submit

错误:

TypeError: user.getIdToken is not a function
     at updateEmailOrPassword (account_info.ts:127:1)
     at updateEmail (account_info.ts:93:1)
     at editEmail (firebase.js:46:1)
     at handlerSubmit (editEmail.js:34:1)
     at HTMLUnknownElement.callCallback (react-dom.development.js:4163:1)
     at Object.invokeGuardedCallbackDev (react-dom.development.js:4212:1)
     at invokeGuardedCallback (react-dom.development.js:4276:1)
     at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4290:1)
     at executeDispatch (react-dom.development.js:9040:1)
     at processDispatchQueueItemsInOrder (react-dom.development.js:9071:1)

我想使用服务 firebase 更新我的 email,即 updateEmail。 如何解决?

updateEmail方法的签名为updateEmail(user, email)

在您当前的代码中,您改为调用updateEmail(auth, email) ,实际上应该是updateEmail(auth.currentUser, email)

注意: updateEmailupdatePassword操作是敏感的,需要用户最近登录,因此请确保您的代码处理 Firebase 拒绝请求的情况。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM