I have this query string.
and I am trying to delete all empty params and make this into
I took this approach.
let searchParams = Object.fromEntries(new URLSearchParams(queryString)) let filteredParams = Object.fromEntries( Object.entries(searchParams).filter(([_, v]) => v != "") ) console.log(new URLSearchParams(filteredParams).toString()) console.log(searchParams)
But I am not sure about this, to use
new URLSearchParams twice, Is it a better and right approach?
Any guidance would be thankful.