简体   繁体   English

如何解决来自我没有创建的文件的“user.getIdToken() 不是函数”错误

[英]how to solve "user.getIdToken() is not a function" error coming from a file I didn't create

So I have a simple project with sveltefire (svelte + firebase).所以我有一个简单的 sveltefire 项目(svelte + firebase)。 I can sign in, I can sign out and I can create an account.我可以登录,我可以退出,我可以创建一个帐户。 In the component to create an account, I have these lines of code:在创建帐户的组件中,我有这些代码行:

        let ActionCodeSettings = {url: 'https://www.Verify.com/?email=' + email };
        await sendEmailVerification(email, ActionCodeSettings).then();
        let result = getRedirectResult(auth);

However, I am getting an error from a file called "email.ts".但是,我从名为“email.ts”的文件中收到错误消息。 I did not create this file, but it gives me:我没有创建这个文件,但它给了我:

 uncaught error in promise user.getIdToken() is not a function.

I put the lines to send an email verification before I create the user, since I don't want to have a false user.在我创建用户之前,我把这些行发送一个 email 验证,因为我不想有一个虚假的用户。 and it should be sending it since I just inputted the email.它应该发送它,因为我刚刚输入了 email。 Is it that the problem?是不是这个问题? if so, is there a work around?如果是这样,是否有解决方法?

If you check the documentation of the sendEmailVerification function it expects a User object as its first argument, while it seems that you are passing in a email address.如果您查看sendEmailVerification function的文档,它期望User object 作为其第一个参数,而您似乎传递的是 email 地址。

You'll need to pass in a User object, for example as shown in the documentation on sending a user verification email :您需要传入User object,例如发送用户验证 email的文档中所示:

mport { getAuth, sendEmailVerification } from "firebase/auth";

const auth = getAuth();
sendEmailVerification(auth.currentUser)
  .then(() => {
    // Email verification sent!
    // ...
  });

暂无
暂无

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

相关问题 在 firebase 中更新密码时出现“TypeError: user.getIdToken is not a function” - Getting "TypeError: user.getIdToken is not a function" when updating password in firebase Error Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first,我该如何解决这个问题? - Error Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first, how can i solve this? 尽管同一模型在另一个文件中工作,但我收到“User.findOne 不是函数”错误消息。 类似的问题答案不起作用 - I am receiving a "User.findOne is not a function" error message despite this same model working in another file. Similar question answers didn't work 如何判断此错误来自哪个文件? - How do I tell what file this error is coming from? 如何解决来自后端层的 Angular 504 错误响应 - How to solve Angular 504 Error Response coming from backend layer 我不明白 javascript 中的创建元素 function - I didn't understand the create element function in javascript TypeError: fn is not a function - 但我没有在我的文件中写 fn - TypeError: fn is not a function - but I didn't write fn in my file 流星:如果用户未创建页面则重定向 - Meteor : redirect if user didn't create page 如何创建 function 将随机字符串(来自数组)分配给某个变量? - How do I create a function that shall assign a random string (coming from an array) to a certain variable? 如何解决错误,filter() 不是函数 - How do I solve the error, filter() is not a function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM