Unhandled promise rejection unknown failure (500) during register and login user

Hello everyone, I’m new to this community and wix website , I have started developing my website and need help on below query, if some one from the community can help/suggest me on below issue will be deeply appreciated.

This issue has been identified when user register themselves in my test website, I have written below code to register user in the website.
"
import wixUsers from ‘wix-users’;
import wixWindow from ‘wix-window’;
import wixLocation from ‘wix-location’;
$w.onReady( function () {
// new code added here
$w(“#submit”).onClick( (event) => {

let emails = $w(“#emails”).value;
let password = $w(“#password”).value;
let firstname = $w(“#firstname”).value;
let lastname = $w(“#lastname”).value

wixUsers.register(emails, password, {
contactInfo: {
“firstName”: firstname,
“lastName”: lastname
}
} )
.then( (result) => {
let resultStatus = result.status;
wixLocation.to(“test/thankyou-page”);
console.log(“registered successfully”);
} );
} );

});

"
and when user register enters all the requisite details and press submit button- Nothing happens , user is not reallocated to the defined wix-location also i can see the below error message in the developers console - "UNHANDLED PROMISE REJECTION UNKNOWN FAILURE(500) "

but being a administrator, i can see a new notification appears on my dashboard confirming me the user is registered successfully. please advise.

Many Thanks
Sushant

Hi Sushant,

Check out the note here
https://www.wix.com/corvid/reference/$w.html#onReady

Generally the onReady event runs twice, once in the backend and once in the browser.
Make sure that you wrap the onClick event inside an IF statement that will only execute it in the “browser” environment.

$w.onReady( function () {
if (wixWindow.rendering.env === “browser”) {
//write the onClick event here
}
});

Thank you so much…I will give a try.

No Luck …Still getting the same error message. :(… please help

I am currently having the same problem. See my post https://www.wix.com/corvid/forum/community-discussion/can-t-get-console-to-log-result-of-register

See https://www.wix.com/corvid/forum/community-discussion/can-t-get-console-to-log-result-of-register