LogoPear Docs
ReferencesBareModules

bare-form-data

Reference for bare-form-data: WHATWG FormData, Blob, and File support for Bare, with a toBlob helper for multipart bodies.

stable

bare-form-data provides the WHATWG FormData, Blob, and File APIs for Bare, plus a toBlob helper to serialize a form into a multipart body. It's pure JavaScript and pairs with bare-fetch.

npm i bare-form-data

Usage

const { FormData, File, toBlob } = require('bare-form-data')

const form = new FormData()
form.append('title', 'Hello form')
form.append('attachment', new File(['My attachment'], 'attachment.txt', { type: 'text/plain' }))

const blob = toBlob(form)

API

FormData

const formData = new FormData()

A multipart form: append(name, value[, filename]), set(name, value[, filename]), delete(name), get(name), getAll(name), has(name). isFormData(value) is a type predicate, and toBlob(formData[, mimeType]) serializes it to a Blob.

Blob

const blob = new Blob(parts[, options])

An immutable binary object: size, type, stream(), and the async readers buffer(), bytes(), arrayBuffer(), text(), plus Blob.isBlob(value).

File

const file = new File(parts, name[, options])

A Blob with a name and lastModified, plus File.isFile(value).

Builds on bare-buffer and bare-stream (see Bare modules).

See also

On this page