I made a lightbox and added two text inputs and a submit button(#button2). I wrote this code but it not loading. The button function is not working.
Please help me
import wixData from 'wix-data';
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';
export function button2_click(event, $w) {
let emailid = $w('#input1').value;
let passkey = $w('#input2').value;
wixData.query("MemberList")
.eq('emailId', emailid)
.eq('password', passkey)
.find()
.then((results) => {
if (results.items.length > 0) {
wixLocation.to(`/quizmain/${results.items[0]._id}`);
}
if (results.items.length === 0) {
$w('#text13').show();
}
})
.catch((err) => {
console.log("err", err);
});
}
Sometimes trailing spaces in the data can be the problem. Try using "contain" rather than "eq" in the query. In other words, instead of the email being written to the collection as "johndoe@gmail.com", it could be "johndoe@gmail.com ". A query utilizing "eq" will not find this email, whereas one using "contain" would because it's looking for the existence of that email in the entire field. It doesn't have to exactly equal it.
.contains('emailId', emailid) .contains('password', passkey)