Skip to content

Instantly share code, notes, and snippets.

@aaronshaf
Created May 28, 2016 16:24
Show Gist options
  • Save aaronshaf/2f866c48088587830e61040cbefdf51c to your computer and use it in GitHub Desktop.
Save aaronshaf/2f866c48088587830e61040cbefdf51c to your computer and use it in GitHub Desktop.
Is there a more terse/blessed way to do this?
Array.from(new FormData(this.refs.form)).reduce((previousValue, currentValue) => {
return Object.assign({}, previousValue, {[currentValue[0]]: currentValue[1]})
}, {})
@vanwagonet
Copy link

vanwagonet commented May 28, 2016

new Map(new FormData(this.refs.form))) Not a plain object, but certainly more terse.

@aaronshaf
Copy link
Author

We end up needing something like https://www.npmjs.com/package/map.prototype.tojson (Map to JSON)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment