Skip to content

A small javascript utility for converting object to formdata

License

Notifications You must be signed in to change notification settings

ankitbrahmbhatt1997/toFormData

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

toFormData

A small javascript utility for converting to form data

npm

Install

npm install @ankit_brahmbhatt/toFormData

Usage

import { toFormData } from "@ankit_brahmbhatt/toformdata";

const object = {
  /**
   * key-value mapping
   */
};

const options = {
  /**
   * Remove null and undefined values from formData object
   */
  removeNullAndUndefined: false,

  /**
   * Use bracket format instead of dot format for js objects . Defaults to false
   */
  useBracketsForObjects: false,
};

const formData = toFormData(
  object,
  options // optional
);

// log formdata to the console
for (let value of formData.entries()) {
  console.log(value[0] + ", " + value[1]);
}

About

A small javascript utility for converting object to formdata

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published