Change image depending on count, different image every time you access the page.

This function was supposed to allow me achieve this goal, it actually works great when working in preview mode, but it does not work on published mode.

#dataset1 has 2 visible columns image and count. There are 8 rows with different images and count has numbers from 1 to 8. The image column from this dataset has been connected to #image54 and in the options I created a filter in which “count” is equal to variable “numero” from #dataset2.
#dataset2 is set on read & write, because we need to get the value “numero” from it, add a +1 to it, check that it never gets past 8, and then save it.

Check website: raiderslp .com/1

import wixData from ‘wix-data’ ;
//imported wixData just in case

$w . onReady ( function () {

$w ( "#dataset2" ). onReady ( () => { 
**let**  count  =  $w ( "#dataset2" ). getCurrentItem (); 
**let**  number1  =  count . numero ; 
**if**  ( number1  >  7 ) { 
    number1  =  0 ; 
} 
number1 ++; 

// up until here everything seems to be working just fine

$w ( "#dataset2" ). setFieldValue ( "numero" ,  number1 ); 
**return**  $w ( "#dataset2" ). save () 
. then (() => {    
     $w ( "#dataset2" ). refresh (); 
}) 

}); 
});