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 example Authorization) are not sent, and
- the body is
{"data": variables, "headers": {...}} instead of variables.
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"} (the variables)
- Header
x-custom: 1 is 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.
Describe the bug
deleteOnein@refinedev/simple-restdoes not send the right body or headers when the HTTP method is changed withmeta.method.The docs ("Default HTTP methods and customizing them") say
meta.methodcan override the HTTP method for every data provider method. ButdeleteOnealways calls:That call shape is only correct for axios
delete(andget/head/options), where the second argument is the request config. Forpost,putandpatch, axios treats the second argument as the request body. So whenmeta.methodis"post","put"or"patch":meta.headers(for exampleAuthorization) are not sent, and{"data": variables, "headers": {...}}instead ofvariables.Steps To Reproduce
Inspect the outgoing request (network tab, or a
nockinterceptor):POST /posts/1x-custom: missing{"data":{"reason":"spam"},"headers":{"x-custom":"1"}}Same result with
meta.method: "put"or"patch".Expected behavior
{"reason":"spam"}(thevariables)x-custom: 1is sentThis matches how
customin the same provider already handlespost/put/patch.Packages
main)Additional Context
Default behaviour (plain
DELETEwith nometa.method) is correct. Only body-carrying method overrides are affected. The same snippet is copied indocumentation/docs/guides-concepts/data-fetching/data-provider-interface.md.I have a fix with tests ready and will open a PR.