Hi,
I’m trying to return few data from backend to frontend once the registration is complete. While testing I can see that the user gets registered successfully but for some reason, the data I return from the backend method to the frontend comes with “undefined”.
Below is my Backend Code
export function doRegistration(email, password, firstName, lastName) {
wixUsersBackend.register(email, password, {
"contactInfo": {
"firstName": firstName,
"lastName": lastName
}
}).then((result) => {
if (result.status === "Pending") {
wixUsersBackend.approveByToken(result.approvalToken)
.then((token) => {
return {
token,
"approved": true,
"userId": result.user.id,
"isEmailExist": false
}
}).catch((err) => {
return {
"approved": false,
"isEmailExist": false,
"errorCode": err.errorCode,
"errorMessage": err.errorDescription
}
});
}
}).catch((err) => {
return {
"approved": false,
"isEmailExist": true
}
});
}
I tried reading the return value from frontend in both the ways as follow:
doRegistration($w('#txtLoginEmail').value, $w('#txtPassword').value, $w('#txtFirstName').value, $w('#txtLastName').value).then(result => {
if (result.approved) { //.approved is undefined
}
});
Also,
let result = doRegistration($w('#txtLoginEmail').value, $w('#txtPassword').value, $w('#txtFirstName').value, $w('#txtLastName').value);
if (result.approved) { //.approved is undefined
}
Any help will be greatly appreciated!