Skip to content
Advertisement

How can I edit the URL without changing pages?

I want to edit the URL of the page without changing to another. Something like this:

For Example: Original URL: localhost:3000/sagsdfgs
             New URL: localhost:3000/fgdgs

Same Host, different URL, same page. I think in react-router-dom there is a function, but I don’t remember what the function is called and I looked for it but I didn’t find it

Advertisement

Answer

Try out !

let url = window.location.toString();
window.location = url.replace(/function=login/, '/function=userloggedIn/');
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement