Why is this function returning undefined?

I am trying to filter my dataset and then assign the result to my repeater content but I keep
getting undefined for the result. items does anyone has a better solution for this issue

import wixData from “wix-data” ;

v ar searchInfo = $w ( ‘#searchInput’ ). value ;
$w ( “#searchButton” ). onClick (()=>{
$w ( “#dataset1” ). setFilter ( wixData . filter ()
. contains ( “_id” , searchInfo )
)

. then (( results ) => { 
    console . log ( "Dataset is now filtered" ); 

//this return undefined when I console.log(result) out

    $w ( "#repeater1" ). data  =  results.items ; 
}). **catch** (( err ) => { 
    console . log ( err ); 
}); 

});

You need $w.OnReady() for your page and dataset. Also be sure collection is read-enabled.

To be more precise → there are even 2x missing onReadys() !!!

$w.onReady(()=>{
	$w('#myDatasetIdhere').onReady(()=>{
		$w("#searchButton").onClick(()=>{myFunction();}
	});
});
function myFunction() {
   $w("#dataset1").setFilter(wixData.filter()
   .contains("_id", searchInfo))
   .then((results)=> {console.log("Dataset is now filtered");
        $w("#repeater1").data = results.items;
    }).catch((err)=> {console.log(err);});
}
1 Like

BTW: → Please no → DOUBLE-POSTINGS!