0.0.10 • Published 2 years ago

form-data-extended v0.0.10

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

Form Data Extended

Build Status Greenkeeper badge

Makes FormData support nested objects and arrays.

As far as I know there are no hard specifications concerning nested multipart requests. This package tries to cater to the most common use cases. Allowing configuration to support different standards could be part of future features.

Installation

npm install form-data-extended --save

Usage

Form data extended exports a single function that takes an object or array. It returns a FormData instance that should be correctly structured.

const formData = require('form-data-extended')

const userFormData = formData({
  name: "John Doe",
  location: {
    country: "USA",
    city: "New York",
  },
  picture: file, // file instanceof File === true
  nicknames: [
    "Johny",
    "Joe",
    "Jo",
  ]
})

userFormData instanceof FormData // => true

The FormData will have the following key value pairs. Notice that it supports file instances too.

name = John Doe
location[country] = USA
location[city] = "New York"
picture = <file>
nicknames[] = Johny
nicknames[] = Joe
nicknames[] = Jo
0.0.10

2 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

5 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

0.0.0

6 years ago