Moralis Register Function (user.signUp)

Hello all

Iā€™m trying to utilize the ā€œuser.signUpā€ command, but I have been stuck for 2 days and canā€™t fix my codeā€¦
I pretty sure it must be some small mistake that I canā€™t seem to find.

 registerAccount = async () => {
  console.log('clicked register');
  const regemail = document.getElementById("regemail").value;
  const regusername = document.getElementById("regusername").value;
  const regpassword = document.getElementById("regpassword").value;
  const regpassword2 = document.getElementById("regpassword2").value;
  const regfirstname = document.getElementById("regfirstname").value;
  const reglastname = document.getElementById("reglastname").value;

    try {  
      const user = new Moralis.User();
      user.set("email", regemail);
      user.set("username", regusername);
      user.set("password", regpassword);
      user.set("firstname", regfirstname);
      user.set("lastname", reglastname);

      await user.signUp(); 
    } catch (error) {
      const code = error.code;
      const message = error.message;
    }
    alert("Account created successfully!")
 
    await Moralis.User.logIn(email, pass);
     //  window.location.href = "dashboard.html"
  }
 
  if (document.querySelector('#btn-register-account') != null) {
    document.querySelector('#btn-register-account').onclick = registerAccount;
  }


any ideas? I donā€™t get an error in the console.

Thanks in advance! :slight_smile:

in case that there is an error, it looks like it doesnā€™t print anything on console, you could add there a console.log(message)

1 Like