-
-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Closed
Description
Describe the issue
I set axios.defaults.headers.common['Content-Type'] = 'application/json'. When firing a axios.patch request (without a config), the request uses application/x-www-form-urlencoded instead.
Example Code
// This does not work as expected:
axios.defaults.headers.common['Content-Type'] = 'application/json'
// This does:
axios.defaults.headers.common['Content-Type'] = 'application/json'
axios.defaults.headers.patch['Content-Type'] = 'application/json'Expected behavior
I expected POST requests to use axios.defaults.headers.common, too.
I think this is where the problem (or intended behaviour) comes from:
axios/lib/core/dispatchRequest.js
Line 46 in 3f53eb6
| config.headers.setContentType('application/x-www-form-urlencoded', false); |
Axios Version
1.4.0
Adapter Version
No response
Browser
Firefox
Browser Version
116.0.3 (64-bit)
Node.js Version
No response
OS
No response
Additional Library Versions
No response
Additional context/Screenshots
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels