Failed to load initial data

Dear All,
I have a lightbox for users to log-in. The moment when it pop up, "Failed to load initial data " showed in console log. What is it? User can log-in without problem even there is error.

This is my code:

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

$w.onReady(() => {

let user = wixUsers.currentUser;
let isLoggedIn = user.loggedIn;

$w("#forgetpw").onClick((event) => { 
    wixUsers.promptForgotPassword() 
       . **catch** ((err) => { 

let errorMsg = err;
});
});

if (isLoggedIn === “true”) {
wixWindow.lightbox.close();
wixWindow.openLightbox(“confirm_apply”);
} else {
// open light box
$w(“#loginenter”).onClick((event) => {

let email = $w(“#loginmail”).value;
let password = $w(“#loginpw”).value;

        wixUsers.login(email, password) 
            .then(() => { 
                console.log("User is logged in"); 
                wixWindow.lightbox.close(); 
                wixLocation.to(wixLocation.url); 
            }) 
            . **catch** ((err) => { 
                console.log(err); 
                $w("#loginerror").expand(); 
            }); 
    }); 

    $w("#closebutton").onClick((event) => { 
        wixWindow.lightbox.close(); 
       
    }); 
} 

});

import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';

$w.onReady(function () {
 $w("#forgotPassword").onClick( (event) => {
    //wixWindow.lightbox.close()
   wixUsers.promptForgotPassword()
   .then( ( ) => {
   //
   } )
    .catch( (err) => {
    let errorMsg = err;  //"The user closed the forgot password dialog"
    });
 });
});

export function loginButton_onclick(event) {

 let email = $w("#email").value;
 let password = $w("#password").value;

 wixUsers.login(email, password)
   .then( () => {
     console.log("User is logged in");
     wixWindow.lightbox.close();
     wixLocation.to(wixLocation.url);  //This reloads the same page.
   } )
    .catch( (err) => {
     console.log(err);
     $w("#errorMessage").expand();  // You can delete this line if you are not going to add an error message. Use a regular text element set to 'collapse on load' from the Properties Panel.
   } ); 
}


Thank you, I have just found that it is not because of the code in the light box as I have copied the above code but I still got the same error. I have even delete all the code but still the same.

It is actually because of my “Site” code. I have a function which check the dataset to see if the member logged in has finished their profile page (if no record found in dataset, that’s mean need to show the create button). If I change the dataset to “everyone can read”, the error disappear but is it safe to do so in the view of protecting my members’ information?

This is my code:

function checklogin() {

if (wixUsers.currentUser.loggedIn) {
let user = wixUsers.currentUser;
let userId = user.id;
$w(“#login”).label = “Logout”;

    user.getEmail() 
        .then((email) => { 

let userEmail = email;
console.log(userEmail);
wixData.query(“cand_reg”)
.eq(“cand_mail”, email)
.find()
.then((results) => {
if (results.items.length === 0) {

                        $w("#createaccount").show(); 
                        $w("#myaccount").hide(); 

                    }  **else**  { 

let item = results.items[0];
//console.log(item);
//console.log(user.id);
$w(“#myaccount”).show();
$w(“#createaccount”).hide();
}

                }) 
        }) 

}  **else**  { 
    $w("#login").label = "Login"; 
    $w("#myaccount").hide(); 
    $w("#createaccount").hide(); 
} 

}

Why not just do a Members Profile as in this tutorial?
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area
https://www.youtube.com/watch?v=Orl8GJNzG5s - Nayeli (Code Queen) video tutorial for above.

Updated video from Nayeli.
https://www.youtube.com/watch?v=yLCOqsVHhD0

Thank you :slight_smile:
Actually I have already read all of them. What I want to do is a bit different but seems that I am not at that level yet…So I have just copy and do the same, still the error appear.

I just found the problem, I have drop a dataset (which I don’t need) to the log-in lightbox by mistake!!!
So silly…