Skip to content

Commit

Permalink
📝 Update .query documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
elbywan committed Aug 24, 2018
1 parent c4db506 commit 03c5cbe
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,33 @@ w = w.query({ reset: true }, true)
// url is now http://example.com?reset=true
```

**Note that .query is not meant to handle complex cases with nested objects.**

For this kind of usage, you can use `wretch` in conjunction with other libraries (like [`qs`](https:/ljharb/qs)).

```js
/* Using wretch with qs */

const queryObject = { some: { nested: 'objects' }}

// Use .qs inside .query :

wretch("https://example.com/").query(qs.stringify(queryObject))

// Use .defer :

const qsWretch = wretch().defer((w, url, { qs }) => (
qs ?
w.query(qs.stringify(qs.query, qs.options)) :
w
))

qsWretch
.url("https://example.com/")
.options({ qs: { query: queryObject }})
/* ... */
```

#### options(options: Object, mixin: boolean = true)

Sets the fetch options.
Expand Down

0 comments on commit 03c5cbe

Please sign in to comment.