formToObject could be simplified to use of two new methods:
FormData.prototype.entries()
Object.fromEntries()
They are supported in Chrome 73+, Firefox 63+ and Safari 12.1+
const formToObject = form =>
Array.from(new FormData(form)).reduce(
(acc, [key, value]) => ({
...acc,
[key]: value
}),
{}
);
const formToObject = form => Object.fromEntries(new FormData(form).entries())
While this is an interesting option indeed, Object.fromEntries() worries me for the time being, due to it being a Draft still. I will put this on hold and we will revisit it in a few months, when this has moved forward a little bit.
Closing due to inactivity. Will reopen when these methods are in a better place so to speak.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for any follow-up tasks.
Most helpful comment
While this is an interesting option indeed,
Object.fromEntries()worries me for the time being, due to it being aDraftstill. I will put this on hold and we will revisit it in a few months, when this has moved forward a little bit.