wixUsers.register() does not get to then() function

Im trying to implement my own registration form and I came across the following issue:

user is being registered to the db, but the code never gets to the “then()” portion of the function. I copy the example from here () and this still happens.

Code that reproduces:

import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
$w.onReady(function () {
    let email = "mm@m.com"// the user's email addresses
    let password = "019283tt"// the user's password
    let firstName = "shira"// the user's first name
    let lastName = "sidfds"// the user's last name
    wixUsers.register(email, password, {
        contactInfo: {
        "firstName": firstName,
        "lastName": lastName
        }
    } ).then( (result) => {
        console.log("GOT TO THEN");
        let resultStatus = result.status;
        wixLocation.to("/home");
} );

});

The user is registered fine, but I never get to the “GOT TO THEN” where I want to redirect the user after registration. I would expect it to register and get to the “then” handler. Please help.

First, please setup your code as shown in previous forum posts.
https://www.wix.com/corvid/forum/community-discussion/light-box-for-registration

Also, make sure that you are testing your site in a live published site as Wix Users API only works properly when on a live site.
https://www.wix.com/corvid/reference/wix-users.html

Note

The APIs in wix-users are only partially functional when previewing your site. View a published version of your site to see their complete functionality.

The APIs in wix-users can only be used once the page has loaded. Therefore, you must use them in code that is contained in or is called from the onReady() event handler or any element event handler.