Property 'then' does not exist on type 'Element' in Wix error. HELP!!!!

import wixUsers from ‘wix-users’ ;
import wixLocation from ‘wix-location’ ;

$w . onReady ( function () {
$w ( ‘#register’ ). onClick ( function (){
let Rank = $w ( ‘#Rank’ ). value ;
let firstName = $w ( ‘#firstName’ ). value ;
let lastName = $w ( ‘#lastName’ ). value ;
let Consistory = $w ( ‘#Consistory’ ). value ;
let email = $w ( ‘#email’ ). value ;
let password = $w ( ‘#password’ ). value ;
let labels = ;

    // const Rank = $w('#Rank').value;   
    // const Consistory = $w('#Consistory').value;   

    // register as member using form data{ 
    "contactInfo" ; { 
    "Rank" ; ( $w ( '#Rank' ). value ), 
    "firstName" ;  $w ( '#firstName' ). value , 
    "lastName" ;  $w ( '#lastName' ). value , 
    "Consistory" ; ( $w ( '#Consistory' ). value )} 
  wixUsers . register ( email ,  password ) 
contactInfo :  
{ 
    "Rank" ; [ Rank ] 
    "firstName" ; [ firstName ] 
    "lastName" ; [ lastName ] 
    "Consistory" ; [ Consistory ] 
    } 
   }) 
   . then ( ( result ) => { 
        **let**  resultStatus  =  result . status ; 
   });

The contactInfo should be part of the arguments to .register. The example there below. Watch the , {. That is missing in your code.

wixUsers.register(email, password, {
12    contactInfo: {
13        "firstName": firstName,
14        "lastName": lastName,
15        "phones": [phone]
16    }
17  } )
18  .then( (result) => {

Additionaly to Giri’s suggested answer…

Perhaps you should also consider to do the registration on backend…

FRONTEND-CODE:

import { myRegisterMemberFunction() } from 'backend/REGISTRATION.jsw'
$w.onReady(()=>{$w('#register').onClick(function(){registerUser();});});
    
function registerUser(){
    let options = {
        contactInfo: {
            firstName: $w('#firstName').value,
            lastName: $w('#lastName').value
        },
        privacyStatus: "PUBLIC"
    }
    myRegisterMemberFunction($w('#email').value, $w('#password').value, options);
}

BACKEND-CODE: (REGISTRATION.JSW)

import { authentication } from 'wix-members-backend';

export function myRegisterMemberFunction(email, password, options) {
return authentication.register(email, password, options)
    .then((member) => {
    return member;
    })
    .catch((error) => {
    console.error(error);
    })
}

I am not a coder so this is all new to me. Right now after using Giri’s suggestions it looks like the only errors are on the 2 lines below.

line 28: “Rank” : ‘Rank’ , error I get states the below.
Type ‘{ Rank: string; firstName: string; lastName: string; Consistory: string[]; }’ is not assignable to type ‘ContactInfo’. Object literal may only specify known properties, and ‘“Rank”’ does not exist in type ‘ContactInfo’. It’s recommended you use a new variable, such as “let newVar = …” to make sure that all code completion work correctly.

last line - }) error I get states the below,
‘}’ expected.
Parsing error: Unexpected token

Additionally, what I am trying to do is to ensure that the 2 custom fields on my members’ registration form are required, and that those fields save the information into the Contacts List. Any help would be greatly appreciated.

@info73208

  1. Please ALWAYS show your current working CODE - - > anybody knows what exactly you are experimenting in front of your monitor (behind the scene).
  2. Do your CUSTOM-FIELDS already exist in your CONTACT(S) ?
  3. Did you read this ?..


https://www.wix.com/velo/reference/wix-users-backend/register

@russian-dima Below is my current code. Yes, my custom fields already exist in my contacts. I did check and make sure that the key:value is exacly as it is typed in my contacts fields list.

import wixUsers from ‘wix-users’ ;
import wixWindow from ‘wix-window’ ;
import wixLocation from ‘wix-location’ ;

$w . onReady ( function () {
$w ( ‘#register’ ). onClick (()=>{ console . log ( “Register-Button clicked” )
let Rank = $w ( ‘#Rank’ ). value ;
let firstName = $w ( ‘#firstName’ ). value ;
let lastName = $w ( ‘#lastName’ ). value ;
let Consistory = $w ( ‘#Consistory’ ). value ;
let email = $w ( ‘#email’ ). value ;
let password = $w ( ‘#password’ ). value ;
let labels = ;

    // const Rank = $w('#Rank').value;   
    // const Consistory = $w('#Consistory').value;   

    // register as member using form data{ 
    "contactInfo" ; { 
    "Rank" ; ( $w ( '#Rank' ). value ), 
    "firstName" ;  $w ( '#firstName' ). value , 
    "lastName" ;  $w ( '#lastName' ). value , 
    "Consistory" ; ( $w ( '#Consistory' ). value )} 

  wixUsers . register ( email ,  password , { 
     contactInfo :  
{ 
    "Rank" : [ Rank ], 
    "firstName" :  firstName , 
    "lastName" :  lastName , 
    "Consistory" : [ Consistory ] 
    } 
   }) 
   . then (( result )=>{ 
let  resultStatus  =  result . status ;  console . log ( resultStatus ) 
wixWindow . lightbox . close (); 
wixLocation . to ( "https://info508482.wixsite.com/orient-of-in" );  

})

@info73208 Perhaps this one will help you out :wink:

Do you have two different posts for same issue running?

Please delete the uneccessary dublicate one.

This has been deleted.

@info73208
Ok some rules for you :grin:

When i wrote to delete your DUBLICATE-POST → there was still no answer in the post.
When you did the deletion, somebody already answerde you. Please pay attention NOT to delete already answered posts.

It is better for you and also feels better for the one, who already answered to your question.

So NEXT TIME → DO NOT DELETE A POST ANYMORE, WHICH ALREADY HAS CONTENT IN IT.

Sorry for the wrong guidance!

@russian-dima I checked the custom fields names and the first letter of each is Capitalized and the rest of the letters are lowercase.

Yet, line 28: “Rank” : ‘Rank’ , still has the error below.
Type ‘{ Rank: string; firstName: string; lastName: string; Consistory: string[]; }’ is not assignable to type ‘ContactInfo’. Object literal may only specify known properties, and ‘“Rank”’ does not exist in type ‘ContactInfo’. It’s recommended you use a new variable, such as “let newVar = …” to make sure that all code completion work correctly.

last line - }) error I get states the below,
‘}’ expected.
Parsing error: Unexpected token

@russian-dima Alright thank you for warning and the info. Now how do I continue to get help on this?

@info73208
@lmeyer
First i will give …


…the chance to REPOST his deleted answer here again.
Now you can just hope, LMeyer is so kind to do a repost here. Let’s wait!

I have updated my code and everything is fine in it accept for the email line of the Contact Info area. Any assistance with this would be greatly appreciated.

@info73208
Take a look at this CONTACT-STRUCTURE_EXAMPLE:

const contactInfo = {
6  name: {
7    first: "Ari",
8    last: "Thereyet"
9  },
10  emails: [
11    {
12      email: "ari.thereyet@example.com",
13    },
14    {
15      email: "ari.thereyet.appended.email@example.com"
16    }
17  ],
18  phones: [
19    {
20      tag: "MOBILE",
21      countryCode: "US",
22      phone: "601-081-124",
23      primary: true
24    }
25  ]
26};

Expected type for EMAIL → is an → ARRAY!
The same for → PHONES!

https://www.wix.com/velo/forum/coding-with-velo/populating-customfields-wix-member-backend