Stop CMS search query if input value empty? IF statement help please

Hi all,

I have a small problem I am sure is easy to solve but I cannot see the syntax error and I am hoping someone smarter than myself can spot the fix… Basically I have the following code which queries a CMS database and populates the repeater with fields on input in the text box. Problem is that when I delete all the text and leave it empty the entire database populates on the page (it searches for a “” blank input and finds this in every entry)

What I need is something like an “IF” statement for if the input value is == “” to stop the code or throw a “false”

Can someone please tell me how to modify the following to achieve this? I just dont want the search to run if the input is empty

$w.onReady(function () {

$w("#repeater1").onItemReady(($item, itemData, index) => {
$item("#pacesExamCentre").text = itemData.pacesExamCentre;
$item("#diet").text = itemData.dietYear;
$item("#cases").text = itemData.cases;
	})

async function search() {
    const query = $w("#input1").value;
    const PACES = await wixData.query("PACEScases").contains("pacesExamCentre", query).find();
    const PACESresult = PACES.items;
    console.log("PACESresult", PACESresult);
    $w("#repeater1").data = PACESresult;
    $w("#repeater1").expand();
}

let throttle;

**$w("#input1").onInput(() => {**

** clearTimeout(throttle);**
** throttle = setTimeout(() => {**
** //if $w(“input1”).value!==“” {**
** // $w(“#repeater1”).collapse();**
** //else**
** search()};**
** }, 500);**
** })**

});

I am highlighting the part where I think the snippet needs to go and what I have tried. Thank you so much!

Another headache… my code as is runs fine in preview but not in live site. So that is a second issue if someone can see why…?