1.0.0 • Published 9 years ago

formulario v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

formulario

Effortlessly turn elements into payloads encoded as multipart/form-data

Install

npm install formulario --save

Usage

You can use formulario with both a <form> element from the DOM or a plain JavaScript object.

var formulario = require('formulario');

formulario(document.querySelector('form'));
formulario({ foo: 'bar' });

You'll get back the necessary headers and the multipart/form-data-encoded request body.

{
  headers: {
    Accept: 'application/json',
    'Content-Type': 'multipart/form-data; boundary=GradualFormBoundary10011100000111011100010001000101'
  },
  body: '--GradualFormBoundary10011100000111011100010001000101\r\ncontent-disposition: form-data; name="foo"\r\n\r\nbar\r\n--GradualFormBoundary10011100000111011100010001000101--'
}

License

MIT