[whatwg/xhr] `FormData`: Accept `object` form in constructor (Issue #387)

### What problem are you trying to solve?

The `FormData` constructor is unergonomic to use for manual construction:

```js
const fd = new FormData();
fd.append("name", "name");
fd.append("file", file);
```

It would be nice if it accepts a object form:
```js
const fd = new FormData({name, file)});
```


### What solutions exist today?

[URLSearchParams()](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/URLSearchParams) is a similar interface that gained support for object form in its constructor.

### How would you solve it?

Extend the standard.

### Anything else?

One drawback is that the `filename` argument to [`append`](https://developer.mozilla.org/en-US/docs/Web/API/FormData/append) can not be provided in object form, but I think it's a non-issue because users can easily generate named `File` objects from `Blob`.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/xhr/issues/387
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/xhr/issues/387@github.com>

Received on Friday, 1 March 2024 16:11:23 UTC