Dataset query fails on live site

Hi,
I have a dataset on site and I added a text element that is supposed to be updated according to query from the dataset. On preview mode it works but on the published site the query fails. This is the code I’m running:
import wixLocation from ‘wix-location’;
import wixData from ‘wix-data’;

$w.onReady( function () {

});

export function users_ready() {
let query = wixLocation.query;
if (query) {
console.log(query)
$w(“#users”).setFieldValue(“referral”, query[“referral”]);
}

wixData.query("register") 

//.eq(“tattoType”, “faces”)
.find()
.then( (results) => {
if (results.items.length > 0) {
let firstItem = results.items[0]; //see item below
console.log("first item is: ", firstItem)
console.log(“list length is: “, results.items.length)
let message = The number of faces is: ${results.items.length}
$w(”#facesCounter”).text = message
} else {
console.log(“query empty”)
}
} )
. catch ( (err) => {
let errorMsg = err;
console.log("query failed: ", errorMsg)
} );

}

The name of the collection is “register” and the name of the dataset element in the page is “users”
The “facescounter” is a text element that I want to update with the counter.

What am I doing wrong?

Hi,
Try checking you collection permissions and make sure you sync your data to live.

1 Like

Thanks mate, it was indeed the permissions :slight_smile: