node-XMLHttpRequest
node-XMLHttpRequest copied to clipboard
FormData not supported!
xmlhttprequest throws an error while sending FormData object as an argument in send method.
var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
var FormData = require('form-data');
var data = new FormData();
data.append("foo", "\"baar\"");
data.append("lorem", "\"ipsum\"");
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log('******');
console.log(JSON.parse(this.responseText));
}
});
xhr.open("POST", "http://httpbin.org/post");
xhr.setRequestHeader("Content-Type", "text/plain");
xhr.send(data);
Running above code snippet throws the following error :
TypeError [ERR_INVALID_ARG_TYPE]:
The "string" argument must be one of type string, Buffer, or ArrayBuffer.
Received type object
@driverdan Please include the support for FormData.
Thanks:)