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

Commit

Permalink
Copy body data for PATCH when sending request.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
infiniteluke authored and facebook-github-bot committed Jun 6, 2017
1 parent a535145 commit 06eec59
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ReactVR/js/Modules/Networking.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export default class Networking extends Module {
headers: headers,
};

// copy over the body data for POST in the correct form
if (method === 'POST' && data) {
// copy over the body data for POST/PATCH in the correct form
if ((method === 'POST' || method === 'PATCH') && data) {
if (data.string) {
options.body = data.string;
} else if (data.formData) {
Expand Down

0 comments on commit 06eec59

Please sign in to comment.