Skip to content

Instantly share code, notes, and snippets.

@sdumetz
Created January 20, 2017 10:53
Show Gist options
  • Save sdumetz/65e16f06466bf22fd93e0ab2212ecc85 to your computer and use it in GitHub Desktop.
Save sdumetz/65e16f06466bf22fd93e0ab2212ecc85 to your computer and use it in GitHub Desktop.
//Rough implementation of application/JSOn formData submission https://darobin.github.io/formic/specs/json/
function jsonFromForm(form){
const formdata = new FormData(form);
//use iterable property of form.keys() to send JSON
const data = {};
for(let key of formdata.keys()){
data[key] = formdata.get(key);
}
return JSON.stringify(data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment