Socket
Socket
Sign inDemoInstall

form-data-extended

Package Overview
Dependencies
4
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    form-data-extended

Extended FormData


Version published
Weekly downloads
30
increased by87.5%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 03 Apr 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc