I am trying to add search and page to my url for searching and pagination on a page.
const urlParams = new URLSearchParams(window.location.search);
if(!urlParams.has('search'){
urlParams.append('search', question);
}
if(!urlParams.has('page'){
urlParams.append('page', pageIndex);
}
This appears to do nothing to the actual url. But when I call urlParams.toString() then I can see that they have been added, but they are not in the actual url in the browser.
I'm using Chrome 107, so it should support it. Am I missing something?
The documentation has not helped me so far.