Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions docs/modules/fetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,34 @@ await fetch('https://api.example.com/data', {
})
```

## `ky`
## `ofetch`

[`ky`](https://github.com/sindresorhus/ky) is a lightweight HTTP client built on top of the Fetch API. It adds convenience features like timeouts, hooks (interceptors), and a simpler API surface.
[`ofetch`](https://github.com/unjs/ofetch) is a small fetch wrapper with automatic JSON parsing, request/response interceptors, and retry support.

Example:

```ts
import ky from 'ky'
import { ofetch } from 'ofetch'

const api = ky.create({
prefixUrl: 'https://api.example.com',
timeout: 5000 // ms
})
const api = ofetch.create({ baseURL: 'https://api.example.com' })

const data = await api.get('users').json()
const data = await api('/user', { query: { id: 123 } })
const created = await api('/items', { method: 'POST', body: { name: 'A' } })
```

## `ofetch`
## `ky`

[`ofetch`](https://github.com/unjs/ofetch) is a small fetch wrapper with automatic JSON parsing, request/response interceptors, and retry support.
[`ky`](https://github.com/sindresorhus/ky) is a lightweight HTTP client built on top of the Fetch API. It adds convenience features like timeouts, hooks (interceptors), and a simpler API surface.

Example:

```ts
import { ofetch } from 'ofetch'
import ky from 'ky'

const api = ofetch.create({ baseURL: 'https://api.example.com' })
const api = ky.create({
prefixUrl: 'https://api.example.com',
timeout: 5000 // ms
})

const data = await api('/user', { query: { id: 123 } })
const created = await api('/items', { method: 'POST', body: { name: 'A' } })
const data = await api.get('users').json()
```
22 changes: 17 additions & 5 deletions manifests/preferred.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"axios": {
"type": "module",
"moduleName": "axios",
"replacements": ["fetch", "ky", "ofetch"],
"replacements": ["fetch", "ofetch", "ky"],
"url": {"type": "e18e", "id": "fetch"}
},
"bluebird": {
Expand Down Expand Up @@ -87,7 +87,7 @@
"cross-fetch": {
"type": "module",
"moduleName": "cross-fetch",
"replacements": ["fetch", "ky", "ofetch"],
"replacements": ["fetch", "ofetch", "ky"],
"url": {"type": "e18e", "id": "fetch"}
},
"crypto-js": {
Expand Down Expand Up @@ -243,7 +243,7 @@
"gaxios": {
"type": "module",
"moduleName": "gaxios",
"replacements": ["fetch", "ky", "ofetch"],
"replacements": ["fetch", "ofetch", "ky"],
"url": {"type": "e18e", "id": "fetch"}
},
"get-stream": {
Expand Down Expand Up @@ -2289,7 +2289,7 @@
"node-fetch": {
"type": "module",
"moduleName": "node-fetch",
"replacements": ["fetch", "ky", "ofetch"],
"replacements": ["fetch", "ofetch", "ky"],
"url": {"type": "e18e", "id": "fetch"}
},
"npm-run-all": {
Expand Down Expand Up @@ -2407,7 +2407,13 @@
"request": {
"type": "module",
"moduleName": "request",
"replacements": ["fetch", "ky", "ofetch"],
"replacements": ["fetch", "ofetch", "ky"],
"url": {"type": "e18e", "id": "fetch"}
},
"retry-request": {
"type": "module",
"moduleName": "retry-request",
"replacements": ["ofetch", "ky"],
"url": {"type": "e18e", "id": "fetch"}
},
"rimraf": {
Expand Down Expand Up @@ -2446,6 +2452,12 @@
"replacements": ["util.stripVTControlCharacters", "Bun.stripANSI"],
"url": {"type": "e18e", "id": "strip-ansi"}
},
"teeny-request": {
"type": "module",
"moduleName": "teeny-request",
"replacements": ["fetch", "ofetch", "ky"],
"url": {"type": "e18e", "id": "fetch"}
},
"tempy": {
"type": "module",
"moduleName": "tempy",
Expand Down
Loading