Skip to content
This repository was archived by the owner on Dec 15, 2020. It is now read-only.

Commit 06eec59

Browse files
infinitelukefacebook-github-bot
authored andcommitted
Copy body data for PATCH when sending request.
Summary: ## Motivation Solves the issue outlined in #218 When `PATCH`ing, the body of the request is not sent. ## Test Plan Inside of a `componentDidMount` or some event handler in your react-vr codebase, add the following code: ```js const payload = { data: { id: 'de0db600-9a0a-416d-b42b-a19d31aad039', attributes: { field_rotation: '-96', field_rotation_x: '10', }, }, }; fetch(`http://httpbin.org/patch`, { method: 'patch', body: JSON.stringify(payload), headers: { "Content-Type": "application/vnd.api+json" } }) .then(res => res.json()) .then(console.log) ``` In the console, you should see <img width="961" alt="react-vr-body-pr-success" src="https://cloud.githubusercontent.com/assets/1127238/26806183/6c97446c-4a04-11e7-9cdb-cba70b0b8def.png"> Thank you for all of your hard work on this project. ❤️ 😄 Closes #219 Reviewed By: amberroy Differential Revision: D5190034 Pulled By: amberroy fbshipit-source-id: 2200ede
1 parent a535145 commit 06eec59

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

ReactVR/js/Modules/Networking.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ export default class Networking extends Module {
6969
headers: headers,
7070
};
7171

72-
// copy over the body data for POST in the correct form
73-
if (method === 'POST' && data) {
72+
// copy over the body data for POST/PATCH in the correct form
73+
if ((method === 'POST' || method === 'PATCH') && data) {
7474
if (data.string) {
7575
options.body = data.string;
7676
} else if (data.formData) {

0 commit comments

Comments
 (0)