A query created using wixLocation.to is attached to all website pages URLs

Hi everyone,

I’m a newbie in Wix coding so I hope anyone here can help me figure out what’s wrong with the following:

I created a button that’s when clicked it takes the user to the ‘search’ page with query in the URL as follows:
export function searchBtn_click(event) {

 wixLocation.to("/search?q="+searchText); 

}

Supposed that searchText value = hello.

So when the search page is loaded, the URL in the URL address bar appears as:
www.website.com/search?q=hello

Everything works fine, except now every page when loaded has its URL appears as follows:
www.website.com/products?q=hello
www.website.com/contact?q=hello
www.website.com/aboutus?q=hello

and so on…

How to prevent the query value from showing on other webpages except the page that the query was sent to (which is search page)?

I ran into the same problem a while back. There is NO solution for it. You cannot clear or reset the query in Wix. It´s a nuisance.