Trying to read data from dataset, getting "failed to load initial data" error

Hello - my site has a dataset which takes an input and in a lightbox shows the total count of the records in the dataset. This works fine in preview mode, but in production the count is not showing in the lightbox. I get the “failed to load initial data” error.

I should mention that an onload function takes the count and updates a textblock in the Lightbox.

Code below:

wixData.query( “subscribers02” )
.count()
.then( (num) => {
let numberOfItems = num;
$w( ‘#waitlistcount’ ).text = num.toString();
} )
. catch ( (error) => {
let errorMsg = error.message;
let code = error.code;
} );

Please help.
Thanks!

Did you sync your sandbox database to the Live?

Also, make sure that you have the correct permissions .

Hi - thanks for your response.

Yes, I’ve sync’d to live. I think the problem may be in the dataset mode? The content is generated through a form - collecting emails - and then the lightbox is meant to display the total count of the same dataset. Is there a better way to do this, maybe in the backend and passing the value through to client to update the field?