Coding issues

Greetings, I’m not able to run my code while publishing it on the main page, it only runs on preview, I haven’t been able to figure out what’s going on, I wrote the following code in the “Site Code section”:

import wixData from ‘wix-data’;

$w.onReady(function () {
wixData.query(“RbeDatabase”)
.count()
.then((num) => {
var numberOfItems = new String(num);
$w(“#conteo”).text = numberOfItems.valueOf();
})
.catch((error) => {
let errorMsg = error.message;
let code = error.code;

	}); 

});

What am I supposed to do in order to run it in the main website???

Hi,
My guess is permission issue.
If it’s not the issue, Try to check the live database.
For more information:
https://support.wix.com/en/article/how-to-set-permissions-for-a-database-collection

Good luck!
Roi

Thanks, yes, it has to do with database permissions issues, I didn’t have to worry about it on other frameworks such as php and mysql, but wix seems to be different in some technicalities, thanks