Hello team wix, I've got my else if statements working for the first 2 but the third else if statement (totalCount === 0) does nothing... There is no dataset being used and the code is on a lightbox. I must be messing up somewhere any suggestions? Thanks in advance!
export function customerlogin_click(event) { let email = $w("#email").value; let userEmail = $w("#email").value; let password = $w("#password").value; wixData.query('VehicleDiagnose') .eq('email', $w('#email').value) .or(wixData.query('VehicleDiagnose') .eq('userEmail', $w('#email').value)) .find() .then((results) => { let resultCount = results.totalCount; if (results.items[0].email === $w('#email').value) { wixUsers.login(email, password) .then( () => { console.log("User is logged in"); wixLocation.to(`/drivers-dashboard`); }) } else if (results.items[0].userEmail === $w('#email').value) { wixUsers.login(email, password) .then( () => { console.log("User is logged in"); wixLocation.to(`/vehicle-diagnose/${userEmail}/home`); }) } else if (totalCount === 0){ $w('#errortext').show(); } }) .catch( (err) => { console.log(err); }); }
I've also tried without count and just the else statement at the end
} else { $w('#errortext').show(); } }) .catch( (err) => { console.log(err); }); }
And still doesn't work ('#errortext') won't show. But the first two wixLocation.to work fine.
so in your case, totalCount will go to undefined if you dont change your code. Hence, it wont be a number or string (undefined)
You have to change totalCount to resultCount OR results.totalCount
the totalCount hasn't been defined in your code, so you have to change it or define it.
Can you put in a code block? (hard to read it now)
This is a code block