cant get collection size after publishing

Hey!

I need to get collection size and set it to the textfield.
Collection is from the form submit
I have this function.

It world in Preview exactly as it should but does not work after publishing.
Whats wrong?


import wixData from 'wix-data';

 function getCounts() {
    wixData.query("subscribers04") //my collection name
    .count()
    .then( (num) => {
 let numberOfItems = Number(num);
    return $w("#text47").text = "" + numberOfItems; //text field ID placed in footer
    } )
    .catch( (error) => {
 let errorMsg = error.message;
 let code = error.code;
    } );
}

 $w.onReady(function () {
  getCounts()

   $w("#box8").hide()
   $w("#getSubscribers1").onWixFormSubmitted(async ({ fields }) => {
  

    try {
      $w("#box8").show()
      getCounts();
    } catch (err) {
        // If any of the promises above failed, the whole promise will be rejected
        return Promise.reject(err);
    }
});

 })

  

Check the collection permissions

thanks, solved