diff --git a/lib/adapters/xhr.js b/lib/adapters/xhr.js index 5da074dde9..d1a7b804b5 100644 --- a/lib/adapters/xhr.js +++ b/lib/adapters/xhr.js @@ -27,6 +27,10 @@ module.exports = function xhrAdapter(config) { } } + if (utils.isFormData(requestData) && utils.isStandardBrowserEnv()) { + delete requestHeaders['Content-Type']; // Let the browser set it + } + var request = new XMLHttpRequest(); // HTTP basic authentication diff --git a/test/specs/formdata.spec.js b/test/specs/formdata.spec.js new file mode 100644 index 0000000000..5c8cca79d0 --- /dev/null +++ b/test/specs/formdata.spec.js @@ -0,0 +1,14 @@ + +describe('FormData', function() { + it('should allow FormData posting', function () { + return axios.postForm('http://httpbin.org/post', { + a: 'foo', + b: 'bar' + }).then(({data}) => { + expect(data.form).toEqual({ + a: 'foo', + b: 'bar' + }); + }); + }); +})