Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

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

License

Notifications You must be signed in to change notification settings

10Pines/object-to-formdata

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

object-to-formdata

npm npm

object-to-formdata is 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,

  /**
   * whether or not to include null values as empty strings in FormData instance
   * defaults to true
   */
  nulls: true
};

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

console.log(formData);

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%