I have the following code in a lightbox that I have setup to be custom registration
console.log("User pressed Submit")
// register as member using form data
wixUsers.register($w('#inputEmail').value, $w('#inputPassword').value, {
"contactInfo": {
"firstName": firstname,
"emails": emails,
}
})
.then((result) => {
let status = result.status
console.log("User registration for: " + $w('#inputEmail').value + " Result: " + status)
})
.catch((err) => {
console.log(err);
})
Only the first console.log gets is fine. But I keep getting a Bad Request error?? any ideas?
When I test on live site I get this…

It would help us if you paste your full code used for this and not just a part of it.
This is a simple signup process for a signup lightbox.
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.
} );
} );
});
Thanks for your response. Yes I have studied those articles many times, but I have to admit that I am struggling to understand js syntax…
The full page code is:
// For full API documentation, including code examples, visit https://wix.to/94BuAAs
import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';
$w.onReady(function () {
let received = wixWindow.lightbox.getContext();
$w('#txtPlan').text = received.planrequested
console.log("Form is ready, planrequested = " + received.planrequested)
$w('#submitButton').onClick(() => {
let emails = [];
emails.push(('#inputEmail').value);
let firstname = $w('#inputFirstname').value;
//let vEmail = $w('#inputEmail').value;
//let password = $w('#inputPassword').value;
console.log("User pressed Submit")
// register as member using form data
wixUsers.register($w('#inputEmail').value, $w('#inputPassword').value, {
"contactInfo": {
"firstName": firstname,
"emails": emails,
}
})
.then((result) => {
let status = result.status
console.log("User registration for: " + $w('#inputEmail').value + " Result: " + status)
})
.catch((err) => {
console.log(err);
})
wixUsers.login($w('#inputEmail').value, $w('#inputPassword').value)
.then(() => {
console.log("User logged in");
})
.catch((err) => {
console.log(err);
})
let toInsert = {
"firstname": firstname,
"email": $w('#inputEmail').value,
};
wixData.insert("Subscribers", toInsert)
.then((newresults) => {
//let item = newresults; //see item below
console.log($w('#inputEmail').value + " has been added to Subscribers")
wixLocation.to("/Free signup");
})
.catch((err) => {
let errorMsg = err;
});
})
})