wixUser.register (fails): Should a constructor be responsible for casting the objects value in a library?

Shouldn’t this code work

It would be better if I could write Example 1. It communicates more clearly and is grammatically correct ( I believe ). I think the constructor should cast to string naturally. Don’t begin to ask me how that is achieved but it would be really nice if I could.


in registerButton_click INFO
registermember INFO

me@here.ca INFO
myPasswordnot INFO
robert INFO
fontain INFO

Error: The value passed to the element selector function (usually $w), must be of type string at...ERROR

  console.log( 'in registermember');
  console.log( $w('#firstnameInput').value);  
  console.log( $w("#lastnameInput").value);
  console.log( $w('#emailInput').value);
  console.log( $w('#passwordInput').value);

 // example 1
  wixUsers.register( $w('#emailInput'), $w('#passwordInput'), {
    contactInfo: {
 "firstName": $w('#firstnameInput'),
 "lastName": $w("#lastnameInput")
    }
  })
  .then((result) => {
    wixLocation.to('/thank-you?msg=MemberRequest');
  })
  .catch((err) => {
    $w('#emailexistsText').show();
  });

  // example 2 - in search of equivalence
  let firstName = $w('#firstnameInput').value;let 
  let lastName = $w('#lastnameInput');
  let email = String($w('#emailInput').value) );
  let password = $w('#passwordInput').toString;

  wixUsers.register( email, password, {
    contactInfo: {
 "firstName": firstName,
 "lastName": lastName)
    }
  })
  .then((result) => {
    wixLocation.to('/thank-you?msg=MemberRequest');
  })
  .catch((err) => {
    $w('#emailexistsText').show();
  });
    
//  example 3 works:

function registerMember() {

 let firstName = $w('#firstnameInput').value;
 let lastName = $w('#lastnameInput').value;
 let email = $w('#emailInput').value;
 let password = $w('#passwordInput').value;
 
    console.log('in registermember');
    console.log( firstName);
    console.log( lastName); 
    console.log( email); 
    console.log( password);

    wixUsers.register(email, password, {
            contactInfo: {
 "firstName": firstName,
 "lastName": lastName
            }
        })
        .then((result) => {
            wixLocation.to('/thank-you?msg=MemberRequest');
        })
        .catch((err) => {
            $w('#emailexistsText').show();
        });
}    

… how do you post executable examples?

Not sure but I suspect " empty-if-missing=true" is clue.

"root":{
"insertId":".........0KVRZXt.N44FQPhr.ylTWS."
"timestamp":"2020-05-06T05:26:07.777Z"
"severity":"ERROR"
"labels":{
"siteUrl":"https://me.here.ca"
"namespace":"Corvid"
"tenantId":"ca75698c-0439-43c3-9905-3a748111d999"
"viewMode":"Site"
"revision":"1184"
}
"operation":{
"id":".........0LhbNUM4lGBD7T8_U.x.lEk"
"producer":"/"
"first":false
"last":false
}
"sourceLocation":{}
"jsonPayload":{
"message":"Error: The value passed to the element selector function (usually $w), 
must be of type string at new MonitoringErrorToIgnore 

(https://me.here.ca/_partials/wix-bolt/1.5775.0/node_modules/viewer-platform-worker/dist/bolt-worker.js:1:29545) 
at WixSelector.value (https://me.here.ca/_partials/wix-bolt/1.5775.0/node_modules/viewer-platform-worker/dist/bolt-worker.js:18:417086) 
at WixSelector.<anonymous> (https://me.here.ca/_partials/wix-bolt/1.5775.0/node_modules/viewer-platform-worker/dist/bolt-worker.js:1:28883) 
at r (https://me.here.ca/_partials/wix-bolt/1.5775.0/node_modules/viewer-platform-worker/dist/bolt-worker.js:18:416725) at https://076b92af-294c-469c-9b31-06c4daf9c146.static.pub.wix-code.com/static/v2/c8da87e0-7041-4217-b404-ecca8dcb5a9f/076b92af-294c-469c-9b31-06c4daf9c146/pages/zcf3l.js?empty-if-missing=true&exclude=wix-&module-name=zcf3l:1:1258 
at t.registerButton_click (https://076b92af-294c-469c-9b31-06c4daf9c146.static.pub.wix-code.com/static/v2/c8da87e0-7041-4217-b404-ecca8dcb5a9f/076b92af-294c-469c-9b31-06c4daf9c146/pages/zcf3l.js?empty-if-missing=true&exclude=wix-&module-name=zcf3l:1:1548) 
at e.<computed> (https://static.parastorage.com/services/wix-code-viewer-app/1.459.0/app.js:25:3496) 
at postMessage_onMessage (https://me.here.ca/_partials/wix-bolt/1.5775.0/node_modules/viewer-platform-worker/dist/bolt-worker.js:18:190465) 
at InternalAPIs.value (https://me.here.ca/_partials/wix-bolt/1.5775.0/node_modules/viewer-platform-worker/dist/bolt-worker.js:18:461654) 
at delegateMessageToSDK (https://me.here.ca/_partials/wix-bolt/1.5775.0/node_modules/viewer-platform-worker/dist/bolt-worker.js:1:152024) 
at https://me.here.ca/_partials/wix-bolt/1.5775.0/node_modules/viewer-platform-worker/dist/bolt-worker.js:1:151599 
at s (https://static.parastorage.com/services/communities-blog-viewer-app/1.627.0/viewer-script.bundle.min.js:1:177379) 
at Generator._invoke (https://static.parastorage.com/services/communities-blog-viewer-app/1.627.0/viewer-script.bundle.min.js:1:177132) 
at Generator.forEach.e.<computed> [as next] (https://static.parastorage.com/services/communities-blog-viewer-app/1.627.0/viewer-script.bundle.min.js:1:177736) 
at asyncGeneratorStep (https://me.here.ca/_partials/wix-bolt/1.5775.0/node_modules/viewer-platform-worker/dist/bolt-worker.js:1:148360) 
at _next (https://me.here.ca/_partials/wix-bolt/1.5775.0/node_modules/viewer-platform-worker/dist/bolt-worker.js:1:151817) 
at https://me.here.ca/_partials/wix-bolt/1.5775.0/node_modules/viewer-platform-worker/dist/bolt-worker.js:1:151933 
at new Promise (<anonymous>) 
at _processMessage (https://me.here.ca/_partials/wix-bolt/1.5775.0/node_modules/viewer-platform-worker/dist/bolt-worker.js:1:151754) 
at https://me.here.ca/_partials/wix-bolt/1.5775.0/node_modules/viewer-platform-worker/dist/bolt-worker.js:1:149798 
at Object.handle (https://me.here.ca/_partials/wix-bolt/1.5775.0/node_modules/viewer-platform-worker/dist/bolt-worker.js:18:124234) 
at https://me.here.ca/_partials/wix-bolt/1.5775.0/node_modules/viewer-platform-worker/dist/bolt-worker.js:1:152154 
at self.onmessage (https://me.here.ca/_partials/wix-bolt/1.5775.0/node_modules/viewer-platform-worker/dist/bolt-worker.js:1:152596)"
}
"receiveTimestamp":"2020-05-06T05:26:09.420Z"
}