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