WIX To insert now failed - it was working fine before?

Hi

This is the second time I’m now contacting… This is getting very ridiculous. Also, at the time of posting WIX had taken down their code reference - it’s back up again now…

This is my code, it has worked for weeks. 346 people have quite happily signed up so far. However, I noticed it’s slowed in the past week and it’s because the code has stopped working… The code is from the WIX create a member database walk through . So, it’s WIX’s code and has been working fine for the past 3/4 weeks.

The code launches the log-in screen mode as expected, but then doesn’t insert the information into my database anymore (anymore being the key-word here… it’s always worked fine but has now stopped) . As a result, the person is a member in the WIX site members collection, but they are not a member in the database collection I use for my dynamic pages.

Could you please tell me what is apparently wrong with it (even though it has always worked) and how to now ‘fix’ it using whatever convoluted method can be produced as a work around…

export function loginButton_click(event) {
  // user is logged in
  if(wixUsers.currentUser.loggedIn) {
    // log the user out
    wixUsers.logout()
      .then( () => {
        // update buttons accordingly
        $w("#box4").collapse();
        $w("#box2").collapse();
        $w("#box3").expand();
        $w("#box1").expand();
    } );
  }
  // user is logged out
  else {
    let userId;
    let userEmail;
  
    // prompt the user to log in 
    wixUsers.promptLogin( {"mode": "login"} )
      .then( (user) => {
        userId = user.id;
        return user.getEmail();
      } )
      .then( (email) => {
        // check if there is an item for the user in the collection
        userEmail = email;
        return wixData.query("Members")
          .eq("_id", userId)
          .find();
      } )
      .then( (results) => {
        // if an item for the user is not found
        if (results.items.length === 0) {
          // create an item
          const toInsert = {
            "_id": userId,
            "title": userId,
            "email": userEmail,
            "firstName": "New Member",
            "points": "5",
            "earned": "5",
            "redeemed": "0",
            "search": "New Member" + userEmail + userEmail,
            "email2": userEmail
          };
          // add the item to the collection
          wixData.insert("Members", toInsert)
            .catch( (err) => {
              console.log(err);
            } );

			      wixWindow.openLightbox("newClient");
			
        }
        // update buttons accordingly
        $w("#box3").collapse();
        $w("#box1").collapse();
        $w("#box2").expand();
        $w("#box4").expand();

      } )
      .catch( (err) => {
        console.log(err);

      
      } );

      
  }

}

Nudging again

HI! Please add site to review as it work in my site - record is inserted after promtlogin.