warning: $w is already declared

Hello and thank you…

I have set up a collection search that uses a user input for the search criteria and a button to run the search. The search results are displayed in a repeater. I am getting a WARNING and the code doesn’t run… but I cannot figure out what is wrong, but I am sure it is really easy.

The page in question:
http://www.mindfulmoment.be/practitioner-r-search-provincie
The WARNING: ‘$w’ is already declared in the upper scope
The CODE:

export function button4_click_1(event, $w) {
//Add your code for this event here:
// Runs a query on the “Members” collection

$w.onReady( function () {

let practitionerInfo = ;
//Query to get the information from the database
wixData.query(“moment-practitioners”)
// Query the collection for any items whose “Name” field contains
// the value the user entered in the input element
.contains(‘provincie’, $w(‘#dropdown1’).value)
.ascending(“postcode”)
.find()
.then((results) => {
practitionerInfo = results.items;
$w(#repeater1).data = practitionerInfo;
})
. catch ((err) => {
let errorMsg = err;
});
//Set the information to the repeater
$w(#repeater1).onItemReady(($w, itemData) => {
//add here all the relevant elements of the repeater
$w(#text27).text = itemData.voornaam;
$w(#text39).text = itemData.naam;
$w(#text1).text = itemData.beroepsactiviteit;
$w(#text1).text = itemData.contexten;
$w(#text46).text = itemData.specialisatie;
$w(#text47).text = itemData.opleiding;
$w(#text48).text = itemData.bijscholing;
$w(#text49).text = itemData.mindfulnessBestaatUit;
$w(#text50).text = itemData.trajectOmMindfulnessTrainer;
$w(#text51).text = itemData.ervaring;
$w(#text35).text = itemData.website;
$w(#text36).text = itemData.email;
$w(#text37).text = itemData.provincie;
$w(#text29).text = itemData.gemeente;
$w(#text43).text = itemData.postcode;
$w(#text33).text = itemData.tel1;
$w(#text34).text = itemData.tel2;

   }); 

// });
});
}

ANY IDEAS? Thank you again, so very much! Cynthia-

Hi Cynthia,
You do not have $w.onReady in the upper scope. it is inside the button4_click_1 function, which defines its own $w to get the button clicked (it is trying to call Object.button4.onReady, and that does not exist). Make sure to close off that function with a curly bracket

export function button4_click_1(event, $w ) {
//Add your code for this event here:
// Runs a query on the “Members” collection
}

Thank you so much, Ethan… I went through the open/close brackets and was unable to determine where I had a mistake there… but I figured it was something like that.

I really appreciate your helping me. Cheers! : -)

No Problem!
I cant read any of it but the Site is looking good.