title: wix button redirect using wixlocation.to
body: <p>I don't know if people use wix here but you all know javascript I guess :)</p>
  
  <p>I created a profile page with a button linking to the create a profile page. </p>
  
  <p>here is the code for the profile page.. </p>
  
  <pre><code>import wixUsers from 'wix-users';
  
  import wixData from 'wix-data';
  
  import wixLocation from 'wix-location';
  
  $w.onReady(function () {
  
    let user = wixUsers.currentUser;
  
    let userId = user.id;
  
    let isLoggedIn = user.loggedIn; // true
  
    user.getEmail()
  
      .then((email) =&gt; {
  
        let userEmail = email;
  
        $w("#emailAddress").value = userEmail;
  
      });
  
    $w("#createProfileButton").onClick(() =&gt; {
  
      let toInsert = {
  
        "firstName": $w("#firstName").value,
  
        "lastName": $w("#lastName").value,
  
        "emailAddress": $w("#emailAddress").value,
  
      };
  
      wixData.insert("Members", toInsert)
  
        .then(() =&gt; {
  
          wixLocation.to("/account/my-profile");
  
        })
  
        .catch((err) =&gt; {
  
          let errorMsg = err;
  
          $w("#error").show();
  
        });
  
    });
  
  });
  </code></pre>
  
  <p>the problem is the create a profile button wont work. It wont redirect. It does nothing. </p>