Skip to content

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

License

Notifications You must be signed in to change notification settings

bevacqua/formulario

Repository files navigation

formulario

Effortlessly turn <form> 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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published