Getting this error on calling `supertokensEmailPas...
# support-questions
s
Getting this error on calling
supertokensEmailPassword.resetPassword
Copy code
emailpassword.js:1 Uncaught (in promise) Error: SuperTokensWindowHandler must be initialized before calling this method.
    at e.getReferenceOrThrow (emailpassword.js:1:105686)
    at t.getQueryParams (emailpassword.js:1:35831)
    at Object.getResetPasswordTokenFromURL (emailpassword.js:1:22726)
    at e.getResetPasswordTokenFromURL (emailpassword.js:1:14504)
    at resetPassword (reset-password?token=NjJjZTUxOTA2MWI2NmE5NmQ2NzYyNjlmOWQyOWE1OTVhZGJiNTYxNWU5NDk3YzU2ZDJlYjNhNTJkYmRkMzU4ZjYwMzM4YmJlOGZkODcyNTRhN2Y0ODQ1YmNkNDZjMmEw&rid=emailpassword:25:70)
r
Hey! Which SDK is this from? And how are you using this SDK?
Also, have you called the supertokens.init function?
s
sdk - web-js yes, I have called supertokens.init fn
I have this on every page on top of all other js scripts
Copy code
supertokens.init({
  appInfo: {
    appName: "...",
    apiDomain:
      "http://localhost:8080" /**Change it to your website domain where this project is deployed */,
    apiBasePath: "/api",
    onHandleEvent: (context) => {
      console.log("SuperTokens event received");
      if (context.action === "UNAUTHORISED") {
        console.log("Unauthorized access");
        alert("You are logged out. Will redirect to login screen.");
        window.location.replace("/auth?redirectToPath=" + location.pathname);
        // called when the user doesn't have a valid session but made a request that requires one
        // NOTE: This event can fire multiple times

        if (context.sessionExpiredOrRevoked) {
          // the sessionExpiredOrRevoked property is set to true if the current call cleared the session from storage
          // this happens only once, even if multiple tabs sharing the same session are open, making it useful for analytics purposes
        }
      }
    }
  },
    recipeList: [
        supertokensSession.init(),
        supertokensEmailPassword.init()
    ],
});
r
Hmm. Got it. And other functions work as expected?
Just this one fails?
s
yes. signin, signup, email token for pass reset. they all work
r
Hmm ok thanks. Can you open an issue about it?
@nkshah2 can help.
n
Hi @sharma, can you post the URLs you used for
supertokens
,
supertokensSession
and
supertokensEmailPassword
when adding them as scripts
We have identified the issue and are working on a fix
s
n
Right, we are working on a fix (will be released today). Ill get back to you on this
Change your script imports to be
Copy code
<script src="https://cdn.jsdelivr.net/gh/supertokens/supertokens-web-js@0.1.3/bundle/website.js" />
<script src="https://cdn.jsdelivr.net/gh/supertokens/supertokens-web-js@0.1.3/bundle/supertokens.js" />
<script src="https://cdn.jsdelivr.net/gh/supertokens/supertokens-web-js@0.1.3/bundle/session.js" />
<script src="https://cdn.jsdelivr.net/gh/supertokens/supertokens-web-js@0.1.3/bundle/emailpassword.js" />
And see if that solves the issue. Note the version in the script URL is just to make sure that jsdelivr does not serve you a cached version (usually takes 24 hours for newer versions to reflect on their CDN)
s
Tried that. I am getting this error now
Copy code
reset-password?token=thetoken&rid=emailpassword:27 Uncaught (in promise) TypeError: supertokensEmailPassword.resetPassword is not a function
n
resetPassword
is not a function, I think you meant to call
submitNewPassword
. Refer to https://supertokens.com/docs/web-js/modules/recipe_emailpassword.html for all the functions you can call
s
submitNewPassword works. Everything is fixed now. Thanks
3 Views