I am registering a member via the backend but am unable to catch the error in case of unsuccessful registration. I would like to display that error. Below is my code, any tips?
BACKEND CODE (.jsw)
import wixUsersBackend from'wix-users-backend';
export function userRegister(email, password, firstName, lastName) {
return wixUsersBackend.register(email, password, {
"contactInfo": {
"firstName": firstName,
"lastName": lastName
}
})
.then( (result) => {
return {"Status":200 , "Message":"Registered successfully"}
})
.catch((err) => {
return {"Status":500 , "Message":err}
});
}
FRONT END CODE
import wixLocation from 'wix-location';
import wixUsersBackend from 'wix-users';
import {userRegister} from 'backend/user';
export function button_click(event) {
userRegister($w('#email').value, $w('#pwd').value, $w('#f').value, $w('#l').value)
.then( (result) => {
if (result["Status"] === 200) {
wixLocation.to("/User?msg=success")
} else {
$w('#errorMsg').text = result["Message"]
$w('#errorMsg').show();
}
})
}