Skip to content

fix(simple-rest): pass body and headers correctly in deleteOne method override - #7614

Open
irongopher75 wants to merge 1 commit into
refinedev:mainfrom
irongopher75:fix/simple-rest-delete-one-method-override
Open

irongopher75 wants to merge 1 commit into
refinedev:mainfrom
irongopher75:fix/simple-rest-delete-one-method-override

Conversation

@irongopher75

Copy link
Copy Markdown

PR Checklist

Please check if your PR fulfills the following requirements:

Bugs / Features

What is the current behavior?

deleteOne in @refinedev/simple-rest always calls:

httpClient[requestMethod](url, { data: variables, headers });

This is correct for axios delete, where the second argument is the request config. But the docs say meta.method can override the HTTP method. When meta.method is "post", "put" or "patch", axios treats the second argument as the request body, so:

  • meta.headers (for example Authorization) are not sent, and
  • the body is {"data": variables, "headers": {...}} instead of variables.

What is the new behavior?

  • For post, put and patch, deleteOne now calls httpClient[method](url, variables, { headers }). The body is variables and the headers are applied.
  • For every other method (delete by default, plus get/head/options), the call is unchanged: httpClient[method](url, { data: variables, headers }). Default behaviour (plain DELETE) is the same as before.
  • The method type is now MethodTypes | MethodTypesWithBody, and the branching uses the same switch style as custom in the same file.
  • The same fix is applied to the copied snippet in documentation/docs/guides-concepts/data-fetching/data-provider-interface.md. Versioned docs are not changed.

Tests added in packages/simple-rest/test/deleteOne/ (nock, following the existing mock style):

  • Default deleteOne sends DELETE with variables as the body and meta.headers applied.
  • meta: { method: "post" | "put" | "patch", headers: { "x-custom": "1" } } sends that method with the body equal to variables (not wrapped) and the custom header present.

The post/put/patch tests fail on main (nock reports no match: the request has no x-custom header and a wrapped body) and pass with this change. pnpm test -- --scope @refinedev/simple-rest passes (30/30), and biome reports no issues.

Resolves #7613

Notes for reviewers

Only body-carrying overrides change. The default DELETE path is unchanged.

@changeset-bot

changeset-bot Bot commented Sep 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1dc11a9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@refinedev/simple-rest Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] simple-rest deleteOne sends wrong body and drops headers when meta.method is post/put/patch

1 participant