isomorphic-form-data

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

MIT 3 个版本
安装
npm install isomorphic-form-data
yarn add isomorphic-form-data
pnpm add isomorphic-form-data
bun add isomorphic-form-data
README

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.

版本列表
2.0.0 2018-07-20
1.0.0 2017-03-08
0.0.1 2015-08-09