-
Notifications
You must be signed in to change notification settings - Fork 49.9k
Description
When attempting to send a JSON request body using the standard fetch API with the HTTP method set to PATCH, the body is consistently ignored or stripped from the request payload. This regression makes it impossible to perform partial updates requiring data transfer via the request body on React projects running version 19.2.0.
The issue is specifically observed when correctly setting the Content-Type: application/json header and stringifying the payload using JSON.stringify().
To Reproduce
- Set up a new React project using version 19.2.0
- Create a component that performs a PATCH request using the fetch API, similar to the code snippet provided below.
- Set a network monitor (e.g., Chrome Devtools, Wireshark) on the target endpoint.
- Execute the handlePatch function.
Minimal Code Snippet:
// This is the structure used to reproduce the bug
const dataToUpdate = { status: 'pending', notes: 'Needs review' };
fetch('[https://api.example.com/items/123](https://api.example.com/items/123)', {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(dataToUpdate),
})
.then(response => response.json())
.then(data => console.log('Response:', data));
// When monitoring the request, the body is empty or not transmitted.
Expected Behavior
The PATCH request should include the serialized JSON object ({"status":"pending", "notes":"Needs review"}) in its body, as specified by the body property of the fetch configuration object.
Observed Behavior
The request is sent with an empty body, or the server-side logging indicates a null/empty body was received, despite the client-side fetch configuration containing a valid JSON.stringify(body).
Environment
- React Version: 19.2.0
- Browser: All (Confirmed on macOS, Windows 11)
- Operating System: All (Confirmed on macOS, Windows 11)
- Environment Type: Standard web browser environment.