Querying Dataset

For some reason when I try to query a dataset being used by a Lightbox subscribers form, it always returns empty even though there are hundreds of items in it. I am querying using this example: https://support.wix.com/en/article/corvid-working-with-the-data-api#querying-your-collection-1

What am I doing wrong?

What am I doing wrong? We don’t know :wink:

Have you used the code example on that page word for word, or have you taken parts of it and used it with other code?

We need to know what you have done and what code you have used etc, so that somebody can help you more.

Please provide in a code block, the code that you have used on your page and any screenshots that might help explain the issue as well.

Lightbox code:

import {sendEmail} from ‘backend/contact’ ;

$w.onReady( function () {
});

export function button2_click(event) {
sendEmail($w( ‘#input1’ ).value);
}

Backend code:

export function sendEmail(email) {
 var exists = false;
    wixData.query("lightboxSubscribe03")
        .eq("emails.email", email) //returns empty set even if this line is commented out
        .find()
        .then( (results) => {
            console.log(results.items); //always returns empty set
 if(results.totalCount > 0) {
                exists = true;
            }
        } );
 if (email.includes("@") && email.includes(".") && !exists) {
        wixCRM.createContact({
 "firstName": email,
 "emails": [email]
            })
            .then((contactId) => {
 var coupons = createCoup(email);
 return wixCRM.emailContact("new_sub", contactId, {
 "variables": {
 "couponCode": coupons[3],
 "couponCode2": coupons[4],
 "couponCode3": coupons[5]
                        }
                    })
                    .then(() => {

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