driverdan / node-XMLHttpRequest

XMLHttpRequest for node.js
http://thedanexperiment.com/2009/10/04/emulating-xmlhttprequest-in-node-js/
MIT License
416 stars 299 forks source link

it doesn't work .send post with form-data #154

Closed ccontarino closed 6 years ago

ccontarino commented 6 years ago

package.json "xmlhttprequest": "1.8.0", "form-data": "2.3.1"

var form = new FormData(); form.append("file", fs.createReadStream(file.path)); form.append('site', site); form.append('environment', environment);

var mothod = 'PUT' var url = "http://localhost:8000/" + method; xhr.open(method, url); xhr.send(form); }

Error TypeError: First argument must be a string or Buffer at ClientRequest.OutgoingMessage.write (_http_outgoing.js:457:11) at exports.XMLHttpRequest.send (/Users/Desktop/proyect/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:467:17)

farzonl commented 6 years ago

seems like you need to JSON stringify your form if you want this to work.