Skip to content

Conversation

@liamcurry
Copy link

This PR adds basic FormData support using the form-data module (same module that request uses). This may not cover all cases, but it's working in my project so I thought I'd share.

Here's an example of how you'd use this to polyfill FormData in Node:

import XMLHttpRequest from 'xhr2';
global.XMLHttpRequest = XMLHttpRequest;
global.FormData = XMLHttpRequest.FormData;

@pwnall
Copy link
Owner

pwnall commented May 1, 2017

Sorry for the late response. This is a feature I'd be interested in, and I like that you followed the choices in request. Can you please add tests?

@mebibou
Copy link

mebibou commented Oct 30, 2018

This doesn't work in this case:

const data = new FormData();
data.append('a', 1);
data.append('b', 1);

In this case, it adds some function in the streams of the FormData forcing the data.on('data') to be completely called asynchronously. In other words, you have to liste to data.on('end') callback function to be sure to have the complete body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants