I have a collection named PG course data collection, from which I’d like to count the number of items and add it to a field #serialNumber on the page. The following code is not working. Any idea what’s wrong?
wixData.query(“PG course data collection”)
.find()
.then( (num) => {
let numberOfItems = num;
$w(“#serialNumber”).value = “”+num+1;
console.log(num);
} )
.catch( (error) => {
let errorMsg = error.message;
let code = error.code;
} );
})