Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormData not supported! #174

Open
vinitshahdeo opened this issue Mar 29, 2019 · 0 comments
Open

FormData not supported! #174

vinitshahdeo opened this issue Mar 29, 2019 · 0 comments

Comments

@vinitshahdeo
Copy link

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:)

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

No branches or pull requests

1 participant