Skip to content

axios.defaults.headers.common not used on PATCH #5825

@twiddler

Description

@twiddler

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:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions