2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-15 11:59:42 +03:00

Fixed FormData posting in browser environment by reverting #3785; (#4640)

* Fixed posting FormData in browser environment by reverting #3785;

* Added ability to keep `Content-Type` header in non-standard browser environments;

* Added browser test of FormData posting using external HTTP service (https://httpbin.org/post);

Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
Dmitriy Mozgovoy
2022-04-27 12:26:52 +03:00
committed by GitHub
parent 82fd15f3d4
commit 76432c18be
2 changed files with 18 additions and 0 deletions
+4
View File
@@ -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
+14
View File
@@ -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'
});
});
});
})