Skip to content

Commit

Permalink
Added POST example to apiFetch README
Browse files Browse the repository at this point in the history
  • Loading branch information
momotofu committed Jan 20, 2020
1 parent 722f7d7 commit 485d694
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/api-fetch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,22 @@ _This package assumes that your code will run in an **ES2015+** environment. If
```js
import apiFetch from '@wordpress/api-fetch';

// GET
apiFetch( { path: '/wp/v2/posts' } ).then( posts => {
console.log( posts );
} );

// POST
apiFetch( {
path: '/wp/v2/posts/1',
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify( { title: 'New Post Title' } ),
} ).then( res => {
console.log( res );
} );
```

### Options
Expand Down

0 comments on commit 485d694

Please sign in to comment.