My code for the custom registration was working fine, but I wanted to redirect the user to their account page in the Member's App using the wixLocation API. I am getting an unexpected token error on my third to last curly bracket/semicolon/parentheses. Please suggest a solution!
TIA
import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
$w.onReady(function () {
$w('#submit').onClick( () => {
// register as member using form data
wixUsers.register($w('#email').value, $w('#password').value,{
"contactInfo": {
"firstName": $w('#firstname').value,
"lastName": $w('#lastname').value,
"emails": [$w('#email').value],
// "phone": ($w('#phone').value),
"position": ($w('#jobtitle').value),
"company": ($w('#company').value),
"industry": ($w('#industry').value),
"employees": ($w('#employees').value),
"street": ($w('#street').value),
"city": ($w('#city').value),
"zip": ($w('#zip').value),
"state": ($w('#state').value)
.then(()=>{
wixLocation.to('/account/my-account');
}
});
});
});
Hi
Could you please help me with a similar problem
id like to do a interactive covered location map
i can give you a example
Thanks in advance !
Eugeniu !
@Yisrael (Wix) For some reason the location is not working anymore. Haven't changed much. I tried re-doing these steps, but I am encountering bracket issues. Please help! Thanks.
Yay! That's a relief since I had trouble with the brackets and parentheses. Glad it worked out. Saves my brain from additional calisthenics.
It worked! Thank you. Huge help.
You're correct, you need a Promise. And in fact, you have one. The .then() is for the fulfillment of the Promise.
You should move the .then() to the end of the .register() function.
You currently have this:
"state": ($w('#state').value) .then(()=>{ wixLocation.to('/account/my-account'); } });
And, if my eyes aren't deceiving me, you should have this instead:
"state": ($w('#state').value) }) .then(()=>{ wixLocation.to('/account/my-account'); } ;
I hope this helps,
Yisrael
Thanks Yisrael. Getting an error at ".then". What should I edit? I believe I need a promise, but not sure how a promise works.
wixUsers.register($w('#email').value, $w('#password').value,{ .then(()=>{ wixLocation.to('/account/my-account');
You have the .then() on "state": ($w('#state').value) and not on register(). You need to move the .then() to the correct location in the code.