Internal error attempting to access Members/PrivateMembersData

Today I am getting an ‘internal error’ on a backend function that has been working fine for months. Here is the (abbreviated) code:

await wixData.query("Members/PrivateMembersData")
.eq(LOGINEMAIL_FIELD, memberEmail)
.find(options)
.then( (results) => {
   if (results.items.length >= 1 ) {
      let currentStatus = results.items[0].status.toLowerCase();
      console.log("Found member whose status is: " + currentStatus);
      if ( currentStatus === "applicant" ) {
         // Delete this user from here and from contacts
         userid = results.items[0]._id;
         removePendingRegistration = true;
      } else {
         // They are already registered with an 'active' status
         response.body = {[RESULT_KEY]: false,[ERRORMSG_KEY] : "user already 
         registered", [STATUS_KEY] : results.items[0].status};
         breakNow = true;
      }
   } else {
      console.log("Did not find member with email: " + memberEmail);
   }
})
.catch( (error) => {
   console.log("Got error attempting to query Members/PrivateMembersData: " +
   error);
   response.body = {[RESULT_KEY]: false,[ERRORMSG_KEY] : error.message};
   breakNow = true;
});
if ( breakNow ) {
   return ok(response);
}

“options” is set as:

let options = {
"suppressAuth": true,
"suppressHooks": true
};

Again, this has been working for a while - now the query generates an error, and the only description is “internal error”.

Help!

T

Did not take a look at the entire thing but the below field LOGINEMAIL_FIELD does not exist in the collection.

.eq(LOGINEMAIL_FIELD, memberEmail)

As Shan has said above about the login email field, you can find the appropriate field in the Wix Members collection here.
https://support.wix.com/en/article/corvid-wix-members-privatemembersdata-collection-fields
Login Email (loginEmail)
https://support.wix.com/en/article/corvid-wix-members-privatemembersdata-collection-fields#login-email-loginemail480

Also, note that there was an issue with the Wix Members collection in Dec 2019, so you might have been affected by this, for more info you can simply search the forum for previous posts about this.

Guys - LOGINEMAIL_FIELD is my own variable - it represents the string “loginEmail” which is in the collection:

(at the top of my backend file):

const LOGINEMAIL_FIELD = “loginEmail”;

I will take a look at the links you provided.

Tad

Btw - if I do a search for a user that is already in the collection - no error. It is only when searching using an email address that doesn’t yet exist in the collection that the error gets thrown.

I looked at the links you provided and I’m doing everything according to those docs. The field name is correct, I’m passing an “options” that suppresses authentication and hooks, etc. Again, this worked fine until recently, and it won’t throw an error if the email address searched for already exists in the collection. It only throws the error if the value searched for doesn’t exist.

Yes, i checked and it seems when the email does not exist it throws an error. Probably a change to the way the collection responds (I think it is under going changes since December) . In any case its best you use the .catch(err) to process the function you wanted to when the email is not found for now.

That is why it is always best to post your full code and not just a snippet of it so that anything like this doesn’t happen.

Plus it might also show sometimes that your problem is in another part of your code and not where you think it is.