Is this the best way to set querystring in using fetchAPI?
const params = new URLSearchParams();
params.set('id', 2);
params.set('word', 'hello');
fetch('https://example.com/?' + params.toString())
I don't think this is the best way because instantiation of URLSearchParams , append the '?' to the end of domain name and using toString method is dull. If I can I want to write as below.
fetch('https://example.com/').params([id:2, word: 'hello']);