Skip to content

Commit

Permalink
The content type option is left to the developer (#4550)
Browse files Browse the repository at this point in the history
* The content type option is left to the developer

If the browser recognizes the fault, it can protect the developer

Although I don't think Axios itself should interfere with developers' choices

This parameter is for compatibility with historical issues

* Update xhr.js

Co-authored-by: Jay <jasonsaayman@gmail.com>
  • Loading branch information
L-Hknu and jasonsaayman committed May 9, 2022
1 parent 9f6ba5e commit 9579bad
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/adapters/xhr.js
Expand Up @@ -28,8 +28,10 @@ module.exports = function xhrAdapter(config) {
}
}

if (utils.isFormData(requestData) && utils.isStandardBrowserEnv()) {
delete requestHeaders['Content-Type']; // Let the browser set it

if (utils.isFormData(requestData) && utils.isStandardBrowserEnv() && !config.defineContentType ) {
// Let the browser set the content type should it not be set
delete requestHeaders['Content-Type'];
}

var request = new XMLHttpRequest();
Expand Down

0 comments on commit 9579bad

Please sign in to comment.