Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bas080/form-data-extended
Form data with nested object and array support
https://github.com/bas080/form-data-extended
Last synced: 21 days ago
JSON representation
Form data with nested object and array support
- Host: GitHub
- URL: https://github.com/bas080/form-data-extended
- Owner: bas080
- License: mit
- Created: 2018-03-02T03:52:56.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-04-03T08:53:38.000Z (over 2 years ago)
- Last Synced: 2024-11-20T05:39:04.700Z (about 1 month ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/form-data-extended
- Size: 61.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Form Data Extended
[![Build Status](https://travis-ci.org/bas080/form-data-extended.svg?branch=master)](https://travis-ci.org/bas080/form-data-extended)
[![Greenkeeper badge](https://badges.greenkeeper.io/bas080/form-data-extended.svg)](https://greenkeeper.io/)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.```javascript
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 =
nicknames[] = Johny
nicknames[] = Joe
nicknames[] = Jo
```