node-XMLHttpRequest icon indicating copy to clipboard operation
node-XMLHttpRequest copied to clipboard

FormData as argument in send method

Open chetandhembre opened this issue 12 years ago • 3 comments

today i try to call xmlhttprequest during that i send argument of type FormData but it is giving error as follow:

TypeError: Argument must be a string

chetandhembre avatar Oct 03 '12 14:10 chetandhembre

FormData is part of the XHR 2 spec which node-XHR is missing most of, including FormData. This is something I'd like to add when I have a chance.

Take a look at @felixge's FormData lib for node: https://github.com/felixge/node-form-data

driverdan avatar Oct 03 '12 15:10 driverdan

I got this working with some hacking earlier and I'd be happy to submit a PR. In my mind, this can be done by adding node-form-data as a dependency and checking if send has been called with an instance of FormData, or by just checking data for getHeaders, pipe, and getLengthSync (and assuming objects with those properties should be treated as a FormData).

Let me know which you'd prefer.

Jeff-Meadows avatar Jul 23 '14 00:07 Jeff-Meadows

:+1: I was about to create this PR. Glad I checked first! This is the solution I was going to do as well. Please accept @driverdan. We need file-upload capability in our client/server SDK and this is a great solution.

jacwright avatar Sep 26 '14 17:09 jacwright