diff --git a/docs/modules/fetch.md b/docs/modules/fetch.md index 06e3aa4..4034ab4 100644 --- a/docs/modules/fetch.md +++ b/docs/modules/fetch.md @@ -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() ``` diff --git a/manifests/preferred.json b/manifests/preferred.json index 9ad252c..d339e50 100644 --- a/manifests/preferred.json +++ b/manifests/preferred.json @@ -15,7 +15,7 @@ "axios": { "type": "module", "moduleName": "axios", - "replacements": ["fetch", "ky", "ofetch"], + "replacements": ["fetch", "ofetch", "ky"], "url": {"type": "e18e", "id": "fetch"} }, "bluebird": { @@ -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": { @@ -243,7 +243,7 @@ "gaxios": { "type": "module", "moduleName": "gaxios", - "replacements": ["fetch", "ky", "ofetch"], + "replacements": ["fetch", "ofetch", "ky"], "url": {"type": "e18e", "id": "fetch"} }, "get-stream": { @@ -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": { @@ -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": { @@ -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",