Skip to content

PATCH requests using fetch adapter #6390

@vojvodics

Description

@vojvodics

Describe the bug

When using the fetch adapter, patch requests are failing

To Reproduce

https://codesandbox.io/p/sandbox/axios-patch-fetch-adapter-nmxp8t

Expected behavior

Patch requests should succeed with fetch adapter

Axios Version

v1.7.0-beta.1

Adapter Version

fetch

Additional context/Screenshots

This is because per spec (https://fetch.spec.whatwg.org/#methods) methods are case-sensitive, and only some methods are normalized, but patch is not one of them.

The solution is to call method.toUpparcase() on 2 places:
https://github.com/axios/axios/blob/v1.x/lib/adapters/fetch.js#L125
https://github.com/axios/axios/blob/v1.x/lib/adapters/fetch.js#L149

Http and xhr adapters do this, probably because of the same reason mentioned above:
https://github.com/axios/axios/blob/v1.x/lib/adapters/http.js#L164
https://github.com/axios/axios/blob/v1.x/lib/adapters/xhr.js#L33

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