npm install formdata-polyfill
This polyfill conditionally replaces the native implementation rather then fixing the missing functions,
since otherwise there is no way to get or delete existing values in the FormData object.
Therefore this also patches
fetch to send the FormData as a blob.
I was unable to patch the Response/Request constructor
so if you are constructing them with FormData you need to call
urlmethod: 'post'body: fd_blob ? fd : fd
The internal data is kept private to prevent unintentional access to it,
WeakMap is used and you may also need a polyfill for that.
If you need to support IE <= 9 then I recommend you to include eligrey's blob.js
Updating from 2.x to 3.x
Previously you had to import the polyfill and use that,
since it didn't replace the global (existing) FormData implementation.
But now it transparently calls
_blob() for you when you are sending something with fetch or XHR,
by way of monkey-patching the
So you maybe had something like this:
var FormData =var fd = formxhr
There is no longer anything exported from the module (though you of course still need to import it to install the polyfill), so you can now use the FormData object as normal:
var fd = formxhr
This polyfill normalizes support for the FormData API:
values(), and support for
- Available in web workers (just include the polyfill)