isomorphic-form-data
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/isomorphic-form-data package

2.0.0 • Public • Published

A library to create readable "multipart/form-data" isomorphically in node and the browser.

Install

npm install isomorphic-form-data

Usage

In this example we are constructing a form with 3 fields that contain a string, a buffer and a file stream.

require('isomorphic-form-data');
var fs = require('fs');
 
var form = new FormData();
form.append('my_field', 'my value');
form.append('my_buffer', new Buffer(10));
form.append('my_file', fs.createReadStream('/foo/bar.jpg'));

node-fetch

You can submit a form using node-fetch:

var form = new FormData();
 
form.append('a', 1);
 
fetch('http://example.com', { method: 'POST', body: form })
    .then(function(res) {
        return res.json();
    }).then(function(json) {
        console.log(json);
    });

License

Form-Data is licensed under the MIT license.

Readme

Keywords

none

Package Sidebar

Install

npm i isomorphic-form-data

Weekly Downloads

119,498

Version

2.0.0

License

MIT

Unpacked Size

2.86 kB

Total Files

5

Last publish

Collaborators

  • dylanpiercey