Clear the query parameters using code?

Hey all!
Let’s say you have the query parameter ?r=bobba in a url in your Wix site and then you use the wixLocation.to(“/login”) and you want that query parameter gone. Is there a way of doing this? It seem that the query parameter is always added to the wixLocation.to command.

1 Like

Hey,
I think this could help you:

import wixLocation from ‘wix-location’;

let baseUrl = wixLocation.baseUrl;
wixLocation.to(baseUrl + “/login”)

you also could get the path if you need it by using (.path):
let path = wixLocation.path;

this link could help you to know more about wix-location:
http://www.wix.com/code/reference/wix-location.html#path

good luck.

1 Like

Andreas, I ran into the same problem a while back. There is no solution: every link suddenly carries the query-part, even links in your menu to homepage, etc. I have tried resetting, deleting, nada.
You can only change values, not delete them. it´s a nuisance.

2 Likes

Hi @Ahmd,

Your method will work…but it will reload the wix webapp which takes lot of time (comparatively)and the page loads from the beginning…

But if use wixLocation.to (“/login”) , the wix web app will not be reloaded and it will move faster to the desired page. But in this case the query parameters follows to the next page…

It is a wix design flow and should be implemented as soon as possible… I am waiting in this forum since 1.5 years to see wix developers implement basic things first instead of sci fiction features… Thanks…

2 Likes

@andreas-kviby I just got into the same problem and for a quick solution that I did was setting the button or the object onClick event to:

export function yourbutton1_click (parameter){
wixLocation.to("http://yoursite.com/login")
}

Let me know what you think. I am curious to see how they will fix this. Best of luck!

1 Like

Same problem here.
Wix:
Surely there must be a way to clear the query so that it doesn’t get appended to every link (even menu links) thereafter?