js fetch encode URL

fetch('https://example.com?' + new URLSearchParams({
    foo: 'value',
    bar: 2,
}))
Enthusiastic Eagle