My code works in preview mode but not on live

Hi! really hope someone can help me.
I’m pretty new in coding on wix and I just did a code for search and dropdown repeater, but the problem is that it only works on preview and publish, but not on live.

This is the code I have:
import wixData from ‘wix-data’ ;
$w ( ‘#resetButton’ ). hide ();

$w . onReady ( function () {

});

export function searchButton_click ( event ) {
search ()
}

function search ( ) {

wixData . query ( “Properties” )
. contains ( “price” , String ( $w ( ‘#dropdown1’ ). value ))
. and ( wixData . query ( “Properties” ). contains ( “zipCode” , $w ( ‘#input4’ ). value ))

. find ()
. then ( results => {
$w ( ‘#propertiesRepeater’ ). data = results . items ;
});
$w ( ‘#resetButton’ ). show ();
$w ( ‘#resetButton’ ). enable ();
$w ( ‘#searchButton’ ). hide ();

}

export function resetButton_click ( event ) {
$w ( ‘#propertiesDataset’ ). setFilter ( wixData . filter ());
$w ( ‘#dropdown1’ ). value = undefined ;
$w ( ‘#input1’ ). value = undefined ;
$w ( ‘#searchButton’ ). show ();
$w ( ‘#searchButton’ ). enable ();
$w ( ‘#resetButton’ ). hide ();

}

Will really appreciate any help.
Best regards

Carolina

Move the second line to the $w.onReady block.

Hi J.D,
Thank you!! it worked beautifully.