Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nervgh/object-to-formdata

[DEPRECATED] Converts json-like object with File, FileList, Blob to FormData object
https://github.com/nervgh/object-to-formdata

Last synced: about 1 month ago
JSON representation

[DEPRECATED] Converts json-like object with File, FileList, Blob to FormData object

Awesome Lists containing this project

README

        

# Object.toFormData()

## Deprecated
See https://github.com/nervgh/recursive-iterator/wiki/Cookbook-(es6)#to-form-data

## About
Converts json-like object with `[File]`, `[FileList]`, `[Blob]` to `[FormData]` object

## Required
[Object.traverse](https://github.com/nervgh/object-traverse), Object.getPrototypeOf, Array.prototype.forEach, Array.prototype.map, window.FormData

## Syntax
```js
// convert object to [FormData]
var form = Object.toFormData(object /*{Object|Array}*/);

// send this object
var xhr = new XMLHttpRequest();
xhr.open('POST', '/');
xhr.onload = function() {
alert(xhr.responseText);
};
xhr.send(form);
```