whatwg/xhr

`FormData`: Accept `object` form in constructor

silverwind opened this issue · 1 comments

What problem are you trying to solve?

The FormData constructor is unergonomic to use for manual construction:

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

It would be nice if it accepts a object form:

const fd = new FormData({name, file)});

What solutions exist today?

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 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.

Thank you, but this has already been reported as #202. Marking as a duplicate therefore.