Last Updated: December 20, 2017
· Evgenia Karunus

How to append a query parameter to a URL?

const url = new URL('');
url.searchParams.set('hello', 'sss')
return url.href; // => ''

url.searchParams returns a URLSearchParams object, which is not yet supported on a couple of browsers.
To make it more browser compatible you can install a polyfill:
npm install --save url-search-params-polyfill
import 'url-search-params-polyfill';