Re: [whatwg/fetch] Provide more ergonomic way of setting request URL's query (#799)

@jfirebaugh how are libraries solving this?
```js
const url = new URL("https://geo.example.org/api");
const params = {lat:35.696233, long:139.570431};
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]));
fetch(url).then(/* … */);
```
doesn't seem too bad (and got a number of updates too), but I could see you might want:
```js
fetch(new URL(url, { search: params })).then(/* … */);

// or

fetch(url, { urlSearch: params }).then(/* … */);
```
but then there would be less flexibility in how parameters get combined with those already present and we'd have to defend why query parameters get special treatment, but paths do not, etc.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/799#issuecomment-650032163

Received on Friday, 26 June 2020 07:42:45 UTC