Skip to content

Commit a08ceaf

Browse files
committed
📝 Update README
1 parent 0dfc5c9 commit a08ceaf

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

README.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<h1 align="center">ya-fetch</h1>
22

3-
[![](https://flat.badgen.net/bundlephobia/minzip/ya-fetch)](https://bundlephobia.com/result?p=ya-fetch)
4-
53
> Super light-weight wrapper around `fetch`
64
75
- [x] Only 1 kB when minified & gziped
@@ -11,6 +9,7 @@
119
- [x] First-class [JSON support](#send--receive-json) (automatic serialization, content type headers)
1210
- [x] [Search params](#params-urlsearchparams--object--string) serialization
1311
- [x] Global [timeouts](#timeout-number)
12+
- [x] [Works in a browser](#-import-in-a-browser) without a bundler
1413
- [x] Written in TypeScript
1514
- [x] Pure ESM module
1615
- [x] Zero deps
@@ -25,10 +24,12 @@ $ npm install --save ya-fetch
2524

2625
```html
2726
<script type="module">
28-
import * as YF from 'https://unpkg.com/ya-fetch/esm/index.js'
27+
import * as YF from 'https://unpkg.com/ya-fetch/esm/min.js'
2928
</script>
3029
```
3130

31+
For readable version import from `https://unpkg.com/ya-fetch/esm/index.js`.
32+
3233
[🔗 Playground on CodePen](https://codepen.io/exah/pen/gOKRYjW?editors=0012).
3334

3435
## ⬇️ Jump to
@@ -42,7 +43,7 @@ $ npm install --save ya-fetch
4243
### Import module
4344

4445
```ts
45-
import * as YF from 'ya-fetch'
46+
import * as YF from 'ya-fetch' // or from 'https://unpkg.com/ya-fetch/esm/min.js' in browsers
4647
```
4748
4849
### Create an instance
@@ -378,13 +379,13 @@ const instance = YF.create({
378379
})
379380
380381
// will have combined `resource` and merged `headers`
381-
const extension = instance.extend({
382+
const extended = instance.extend({
382383
resource: '/posts'
383384
headers: { 'X-Something-Else': 'Bar' },
384385
})
385386
386387
// will send request to: 'https://jsonplaceholder.typicode.com/posts/1'
387-
await extension.post(1)
388+
await extended.post(1, { json: { title: 'Hello' } })
388389
```
389390

390391
##### Related
@@ -691,7 +692,7 @@ const posts = instance.extend({
691692
})
692693
693694
// will send request to 'https://jsonplaceholder.typicode.com/posts'
694-
await posts.get()
695+
const result = await posts.get().json() // → [{ id: 0, title: 'Title', ... }]
695696
```
696697

697698
##### Related

0 commit comments

Comments
 (0)