SBVA- Button Click and Data Query

I have a simple page where I need to validate an email ID that user enters against my database. I created a simple collection called “DLPRegisteredStudents” where there are fields such as EMail_ID, Date_Registered, Date_Ended, and Active_Flag. I created a page with just one input field accepting Email ID and a button to Validate. For some reason the WixData.query function is not working for me. Here is the code: Can someone help me??

export function button1_click_1(event) {
//Add your code for this event here:
console.log(“Came Here”)
wixData.query(“DLPRegisteredStudents”)
.eq(“Email_ID”,$w(‘#emailEntered’))
.eq(“Acive_Flag”, “Yes”)
.find()
.count()
.then((num) => {
let numOfEmails = num;
})
.then((results) => {
if (results.items.length > 0) {
let items = results.items;
let firstItem = items[0];
console.log(results.items);
$w(“#DateRegistered”).text = “Date Registered: " & results.Date_Registered;
$w(”#DateEnded").text = "Date Ended: " & results.Date_Ended;
//display the Registered Date and End Date values read…
$w(‘#DateRegistered’).isVisible;
$w(‘#DateEnded’).isVisible;
} else {

            $w("#emailEntered").value = "Invalid or Inactive Email ID. Please try again" 

// $w(‘#emailNotFoundMsg’).isVisible
// handle case where no matching items found
}
})
. catch ((error) => {
let errorMsg = error.message;
let code = error.code;
});
}

To resolve your issue, delete the count() method code and use let numOfEmails = result.items.length to get the count of the search results. You don’t need this part of your code:

.then((num) => { let numOfEmails = num; })

Thanks for the quick response Sam. I did what you suggested, but there is no difference in the behavior. Basically when I click the validate button, nothing happens as if it is not even executing the button1_click_1 procedure. here is how it looks now:

export function button1_click(event) {
//Add your code for this event here:
console.log(“Came Here”)
wixData.query(“DLPRegisteredStudents”)
.eq(“Email_ID”,$w(‘#emailEntered’))
.eq(“Acive_Flag”, “Yes”)
.find()
//.count()
.then((results) => {
let numOfEmails = results.items.length
if (numOfEmails > 0) {
let items = results.items;
let firstItem = items[0];
console.log(results.items);
$w(“#DateRegistered”).text = “Date Registered: " & results.Date_Registered;
$w(”#DateEnded").text = "Date Ended: " & results.Date_Ended;
$w(‘#DateRegistered’).isVisible;
$w(‘#DateEnded’).isVisible;

Just to make sure it is going to that procedure I included console.log (“Came Here”) but that does not show up in the developer console.

What am I missing?