Created
April 4, 2018 04:00
-
-
Save sbussard/225d8cc0e663b7f44409915e68d145a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// given a form element | |
// get its children that have a name attribute | |
// map to { name, value } objects | |
// reduce individual into one { [name]: value } object | |
export default formElement => Array.from(formElement.querySelectorAll('[name]')) | |
.map(({ name, value }) => ({ name, value })) | |
.reduce((current, item) => ({ ...current, [item.name]: item.value }), {}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment