Skip to content

Commit

Permalink
📝 Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
elbywan committed Oct 3, 2017
1 parent c79578a commit b8f3cc8
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions README.md
Expand Up @@ -100,12 +100,35 @@ wretch("endpoint")
.res(response => /* ... */)
```

#### Because configuration should not rhyme with repetition.

```javascript
// Wretch is immutable which means that you can configure, store and reuse objects

const corsWretch = wretch().options({ credentials: "include", mode: "cors" })

// sends a cors request
corsWretch.url("...").get()

// Refine the cors wretch by adding a specific header and a fixed url
const corsWretchWithUrl = corsWretch.url("http://myendpoint.com").headers({ "X-HEADER": "VALUE" })

corsWretchWithUrl.get()
corsWretchWithUrl.json({a:1}).post()

// Reuse the original cors wretch object but this time by adding a baseUrl
const corsWretchWithBaseUrl = corsWretch.baseUrl("http://myurl.com")

corsWretchWithBaseUrl("/root").get()
corsWretchWithBaseUrl("/data/1").get()
```

# Installation

## Npm

```sh
npm i -D wretch
npm i wretch
```

## Clone
Expand Down Expand Up @@ -155,7 +178,7 @@ var wretch = require("wretch")

## Code

*Wretcher objects are immutable.*
**Wretcher objects are immutable.**

```javascript
wretch(url, options)
Expand Down Expand Up @@ -306,7 +329,6 @@ const id = await blogs("").json({ name: "my blog" }).post().json(_ => _.id)
const blog = await blogs(`/${id}`).get().json()
console.log(blog.name)
await blogs(`/${id}`).delete().res()
// ... //
```
#### query(qp: Object)
Expand Down

0 comments on commit b8f3cc8

Please sign in to comment.