Last active
December 13, 2017 15:01
-
-
Save VitorLuizC/077e8191884c1693ee76986b2544bd6b 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
/** | |
* Cast object in a FormData. | |
* @param {object} object | |
* @returns {FormData} | |
*/ | |
export const toFormData = (object) => { | |
const entries = Object.entries(object) | |
const form = entries.reduce((form, [ name, value ]) => { | |
form.append(name, value) | |
return form | |
}, new FormData()) | |
return form | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment