Hot to load next() page or load more items in a repeater using wix-Data API

I can’t find any recourses for how create pegination or load more in editorX using wix-Data.
With my code I managed to load data only one time(2nd page kinda), second click returning error.

export function stylesRepeater (){
$w ( “#myRepeater” ). onItemReady ( ( $item , itemData , index ) => {
$item ( “#text1” ). text = itemData.sku ;
} );

let allItems

wixData . query ( “Styles” )
. limit ( 3 )
. find ()
. then ( result =>{
allItems = result.items ;
$w ( “#myRepeater” ). data = allItems ;
console . log ( allItems )
console . log ( result . hasNext ())
$w ( “#btnTest” ). onClick ( ( event ) =>{
if ( result . hasNext ()) {
result . next ()
. then (( results ) =>{

                      allItems  =  allItems . concat ( results.items ); 
                      $w ( "#myRepeater" ). data  =  allItems 
                      
                    })           
                    
        } **else**   {  $w ( "#btnTest" ). hide () 
       
        } 
      })        
      
   }); 

}

1 Like