[BUG] simple-rest deleteOne sends wrong body and drops headers when meta.method is post/put/patch
Describe the bug
deleteOne in @refinedev/simple-rest does not send the right body or headers when the HTTP method is changed with meta.method.
The docs ("Default HTTP methods and customizing them") say meta.method can override the HTTP method for every data provider method. But deleteOne always calls:
const requestMethod = (method as MethodTypesWithBody) ?? "delete";
const { data } = await httpClient[requestMethod](url, { data: variables, headers });That call shape is only correct for axios delete (and get/head/options), where the second argument is the request config. For post, put and patch, axios treats the second argument as the request body. So when meta.method is "post", "put" or "patch":
- headers from
meta.headers(for exampleAuthorization) are not sent, and - the body is
{"data": variables, "headers": {...}}instead ofvariables.
Steps To Reproduce
import dataProvider from "@refinedev/simple-rest";
const provider = dataProvider("https://api.example.com");
await provider.deleteOne({
resource: "posts",
id: "1",
variables: { reason: "spam" },
meta: { method: "post", headers: { "x-custom": "1" } },
});Inspect the outgoing request (network tab, or a nock interceptor):
- Method:
POST /posts/1 - Header
x-custom: missing - Body:
{"data":{"reason":"spam"},"headers":{"x-custom":"1"}}
Same result with meta.method: "put" or "patch".
Expected behavior
- Body:
{"reason":"spam"}(thevariables) - Header
x-custom: 1is sent
This matches how custom in the same provider already handles post/put/patch.
Packages
- @refinedev/simple-rest: 6.0.1 (current
main) - axios: ^1.11.0
Additional Context
Default behaviour (plain DELETE with no meta.method) is correct. Only body-carrying method overrides are affected. The same snippet is copied in documentation/docs/guides-concepts/data-fetching/data-provider-interface.md.
I have a fix with tests ready and will open a PR.
Source: refinedev/refine