Alex Z
Oct 15, 2022

--

You should definitely not use reduce() to format your search parameters! You should use the URL Object (linked below) and then modify or access the search params using the .searchParams property of that object.

// https://some.site/?id=123
const parsedUrl = new URL(window.location.href);
console.log(parsedUrl.searchParams.get("id")); // "123"
https://developer.mozilla.org/en-US/docs/Web/API/URL

--

--

Alex Z
Alex Z

Written by Alex Z

Software Developer + Product Manager. Interested in Travel, Culture, Economics and the Internet. Join Medium: https://tinycode.medium.com/membership

No responses yet