Home > Net >  how to solve "user.getIdToken() is not a function" error coming from a file I didn't
how to solve "user.getIdToken() is not a function" error coming from a file I didn't

Time:08-08

So I have a simple project with 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". 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. and it should be sending it since I just inputted the email. Is it that the problem? if so, is there a work around?

CodePudding user response:

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.

You'll need to pass in a User object, for example as shown in the documentation on sending a user verification email:

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

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