Is there any method to get the URL without query string?

Try this:

let path = window.location.href.split('?')[0]
console.log({path})

Leave a Comment