Hello here,
I was following the wix tutorial:
https://support.wix.com/en/article/velo-tutorial-creating-a-custom-registration-form-with-code#prerequisites
But when applying the final code, I have an error that says:
I use the same part of code, I just added an async function but with or without I get the same error.
$w.onReady(()=>{console.log('Page is ready') ;
// ---------- Waiting for Database 1 to load --------
$w('#dataset1').onReady(()=>{
console.log('Dataset1 ready') ;
// ---------- Waiting for Database 2 to load --------
$w('#dataset2').onReady(()=>{
console.log('Dataset2 ready') ;
console.log("===== Start of the code =====");
// ******************************** Send the form ********************************
let emails = [] ;
$w('#bInscription').onClick( async () => {
console.log("===== Button Registration =====") ;
let newId = memory.getItem("key") ;
console.log("New iD Client memory: " + newId) ;
// ---------- WIX DB data --------
const password = $w('#iMdp').value ;
let sponsor = $w('#iSponsor').value ;
const email = $w('#iMail').value ;
emails.push(email) ;
let options = {
contactInfo : {
firstName : String($w('#iFirstName').value),
lastName : String($w('#iName').value),
emails : emails,
Sponsor : Number(sponsor),
CustomerId : Number(newId)
},
privacyStatus : 'PUBLIC'
}
// ---------- Registration verification --------
await authentication.register(email, password, options)
.then((registrationResult) => {
const status = registrationResult.status ;
// When the site is configured for automatic approval, the status is "ACTIVE" and the member is approved and logged in.
console.log('Member registered and logged in:', registrationResult) ;
})
.catch((error) => {
console.error(error) ;
}) ;
}) ;
}) ;
}) ;
}) ;
Both “Sponsor” and “CustomerId” have been added to the contacts in number format manually.
Can anyone help me?