Skip to content

Instantly share code, notes, and snippets.

@petermoresi
Last active April 30, 2019 20:37
Show Gist options
  • Save petermoresi/703b80178e787e283194ded3dce447d3 to your computer and use it in GitHub Desktop.
Save petermoresi/703b80178e787e283194ded3dce447d3 to your computer and use it in GitHub Desktop.
let formData = new FormData();
formData.append("name", "Tom");
[...formData.keys()].reduce((acc, key) => ({ ...acc, [`${key}`]: formData.get(key) }), {})
@petermoresi
Copy link
Author

This ES6 code can be used to convert any GeneratorFunction into a regular JS Object.

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