Skip to content

Commit

Permalink
Add image to README
Browse files Browse the repository at this point in the history
  • Loading branch information
maetl committed Dec 3, 2015
1 parent b81d26d commit 43c262f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Piggyback

A resource-oriented wrapper over the window.fetch API. Defaults to JSON content type.
A resource-oriented wrapper over the `window.fetch` API. Defaults to the JSON content type.

<img src="http://i.imgur.com/xbbu240.jpg" width="640" title="Piggybacking space shuttle on 747">

## Install

Expand All @@ -11,28 +13,28 @@ npm install --save piggyback
## Usage

```js
import { getFetch, postFetch, putFetch, deleteFetch } from 'piggyback';
import { sendGet, sendPost, sendPut, sendDelete } from 'piggyback';

export default function getPosts() {
return getFetch('/posts').then(function(response) {
return sendGet('/posts').then(function(response) {
return response.json();
});
}

export default function createPost(body) {
return postFetch('/posts', body).then(function(response) {
return sendPost('/posts', body).then(function(response) {
return response.json();
});
}

export default function updatePost(id, body) {
return putFetch('/posts/' + id.toString(), body).then(function(response) {
return sendPut('/posts/' + id.toString(), body).then(function(response) {
return response.json();
});
}

export default function deletePost(id) {
return deleteFetch('/posts/' + id.toString());
return sendDelete('/posts/' + id.toString());
}
```

Expand Down

0 comments on commit 43c262f

Please sign in to comment.