Hello Covid Masters,
I have the following code in public and it is working fine except that it does not return “Success” text. instead, it returns {} you can see the site event snapshot.
Please, help me to find what is wrong with it.
export async function Register(email, password, name, phone, ReferrerId) {
await wixUsers.register(email, password, {
"contactInfo": {
"firstName": name,
"phones": [phone]
}
})
.then((result) => {
console.log("New User - " + result.status + " - " + result.user.id);
/////////Action after sign in////////
if (result.user.loggedIn) {
let Referrer = ReferrerId;
let Referee = {
referrerId: Referrer._owner,
refereeId: result.user.id,
};
wixData.insert("Referee", Referee)
.then(() => {
console.log("Referee added");
AddXP(result.user, 300, "First sign in")
.then(() => {
console.log("Done");
return "Seccess";
});
})
.catch((error) => {
console.log("Referee insert error -" + error);
});
} else {
console.log("User not logged in");
return "notLoggedIn"
}
})
.catch((error) => {
console.log("Registeration error - " + error);
return "Error";
});
}