I’m using wix users to register people to my site.
This is the code i use.
wixUsers.register(email, password, {
contactInfo: {
"firstName": firstName,
"lastName": lastName
}
})
.then((result) => {
wixLocation.to(wixLocation.baseUrl);
})
.catch((err) => {
let errorMsg = err;
console.log(errorMsg);
});
The problem is that sometimes users contact me to tell me that they can’t register because of the following error:
mainr.js:126 POST https://www.letsmeet.co.il/_api/wix-sm-webapp/v1/auth/register 500 (Server Error)
console.js:35 Cannot read property ‘member’ of null
Any idea what can i do about it? this API is not very stable… 90% of the time it works ,but sometimes is not.
Thanks.
‘null’ most of the time means empty field or undefined or the dataset had not loaded etc.
Also, why are you using base url?
https://www.wix.com/corvid/reference/wix-location.html#baseUrl
When all it seems is that you just need to direct your users back to the home page.
https://www.wix.com/corvid/reference/wix-location.html#to
This works perfectly for me and closes after registering details before moving user onto my sign-up status page, then both names will be saved in contacts and once site member is manually approved the member details will be added to ‘members’ database.
import wixUsers from 'wix-users';
import wixWindow from 'wix-window';
import wixLocation from 'wix-location';
$w.onReady(function () {
$w("#registerButton").onClick( (event) => {
let email = $w("#email").value;
let password = $w("#password").value;
let first = $w("#firstName").value;
let last = $w("#lastName").value;
wixUsers.register(email, password, {
contactInfo: {
"firstName": $w('#firstName').value,
"lastName": $w('#lastName').value,
}
} )
.then( (result) => {
let resultStatus = result.status;
wixWindow.lightbox.close();
wixLocation.to("/sign-in-status"); //Change the URL ending to whatever page you want to send the user to after they log in.
} );
} );
});