Skip to content

Latest commit

 

History

History
30 lines (25 loc) · 548 Bytes

README.md

File metadata and controls

30 lines (25 loc) · 548 Bytes

object-to-formdata

A convenient JavaScript function that converts an object to a FormData instance

const objectToFormData = require('object-to-formdata')

const object = {
  /**
   * key-value mapping
   * values can be primitives or objects
   */
}

const options = {
  /**
   * whether or not to include array indices in FormData keys
   * defaults to false
   */
  indices: false
}

const formData = objectToFormData(
  object,
  options, // optional
  existingFormData, // optional
  keyPrefix // optional
)

console.log(formData)