Summary
useMutation always calls
esponse.json() after any
esponse.ok result in packages/data/src/hooks/useMutation.ts. Successful mutation endpoints often return 204 No Content or another empty body, so the hook throws a JSON parse error even though the HTTP request succeeded.
Reproduction
- Use useMutation('/resource/1', 'DELETE') against an endpoint that returns 204 No Content.
- Call mutate(undefined).
- The fetch succeeds, but �wait response.json() rejects because there is no body.
Expected behavior
A successful empty response should be treated as a successful mutation. The hook could return
ull/undefined, avoid setting an error, and still increment mutationCount.
Actual behavior
The mutation is reported as failed with a parse error, even though the server returned a successful status.
Summary
useMutation always calls
esponse.json() after any
esponse.ok result in packages/data/src/hooks/useMutation.ts. Successful mutation endpoints often return 204 No Content or another empty body, so the hook throws a JSON parse error even though the HTTP request succeeded.
Reproduction
Expected behavior
A successful empty response should be treated as a successful mutation. The hook could return
ull/undefined, avoid setting an error, and still increment mutationCount.
Actual behavior
The mutation is reported as failed with a parse error, even though the server returned a successful status.