Hi, I created a similar post a few weeks ago when I forgot to add the ‘suppressAuth: true’ option to my data queries from the backend modules. I was getting an error and nothing returned when signing up to my ‘PrivateMembersData’ collection but that issue has since been resolved.
I now use multiple web modules for my signup process, using the 'PrivateMembersData 'for actual login and an extra collection called ‘UserInfo’ for any additional information I need. I made a function that handles sending all the necessary information to my ‘UserInfo’ collection called ‘saveUserInfo’.
This function worked completely fine a couple of days ago, but I’ve since added extra behaviour to my signup process to make it feel complete so I’m sure I’ve accidentally broken it somehow but I’m not sure exactly where. My page code works completely fine until calling this web module function:
export function saveUserInfo(_email, _username, _referralCode) {
let regExpEmail = new RegExp("^([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{0,50})$");
let regExpUser = new RegExp("^[a-zA-Z0-9]{5,20}$");
let regExpRef = new RegExp("^([A-Za-z_][A-Za-z0-9_]*){0,20}$");
if (regExpEmail.test(_email) && regExpUser.test(_username) && regExpRef.test(_referralCode)) {
let toInsert = {
"email": _email,
"username": _username,
"referralCode": _referralCode,
"subscription": false
};
let options = {
"suppressAuth": true,
"suppressHooks": false
};
return wixData.insert("UserInfo", toInsert, options)
.then( (results) => {
return "SUCCESS";
})
.catch( (err) => {
return "INSERT ERROR";
});
}else {
return "INVALID DATA";
}
}
Anything after my ‘.then(result =>’ just doesn’t run at all so something seems to be going wrong in the above code. It’s almost the exact same problem that I’ve had before but this time its inserting data into a collection, and this time I’ve included the options that I should have.
My ‘UserInfo’ collection is the Private Data type and all permissions are set to admin, I wouldn’t have thought this would be a problem when accessing it using a web module though. Even setting the create content permission to ‘anybody’ results in the same error.
Does anybody know what I’ve done wrong?