I have the following code enabling a user to sign up in the backend:
export function signup(username, email, password) {
return new Promise((resolve, reject) => {
try {
let toInsert = {
'title': username,
'email': email,
'password': password,
'wsmoStatus': false,
'ssmoStatus': false
};
wixData.insert('members', toInsert, options)
.then(() => {
authentication.register(email, password)
.then(() => {
resolve('success');
})
.catch((err) => {
removeItemMembers(email);
resolve(err);
});
})
.catch((err) => {
resolve(err);
});
} catch (err) {
resolve(err);
}
});
}
I have a private data collection “members” to which I try to input the info provided. The “options” contains suppressAuth and suppressHooks. I call this from the frontend this way:
import { signup } from 'backend/MemberBackend';
import wixLocation from 'wix-location';
$w.onReady(function () {
$w('#signup').onClick(() => {
let username = $w('#username').value;
let email = $w('#email').value;
let password = $w('#password').value;
console.log(username, email, password);
signup(username,email,password)
.then((result) => {
if(result === 'success'){
wixLocation.to('/my-profile');
} else {
console.log(result);
console.log('Error. Could not signup');
//TODO: Add error message DOM
//TODO: See what types of errors are returned
}
})
.catch((err) => {
console.log(err);
console.log('Oops! An error has occured. Could not signup.');
//TODO: Add error message DOM
//TODO: See what types of errors are returned
});
});
});
However, in the console on my website when I try this, it gives me the following error:
Error: Unable to handle the request. Contact the site administrator or view site monitoring logs for more information.
Why is this happening? Thanks in advance.