| layout | home | |||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| title | openFetch — fetch-native HTTP client | |||||||||||||||||||||||||||||||||||||||||||||||||
| titleTemplate | false | |||||||||||||||||||||||||||||||||||||||||||||||||
| description | Fetch-native HTTP client with interceptors, middleware, Standard Schema JSON, retry lifecycle hooks, memory cache, and Ky-style ergonomics — Node 18+, edge, browsers. No XHR. | |||||||||||||||||||||||||||||||||||||||||||||||||
| head |
|
|||||||||||||||||||||||||||||||||||||||||||||||||
| hero |
|
|||||||||||||||||||||||||||||||||||||||||||||||||
| features |
|
The EscuelaJS categories API returns a JSON array. Below: openFetch, Axios, and ky.
openFetch — shared defaults, structured response, and room for interceptors/middleware:
import openFetch from "@hamdymohamedak/openfetch";
const res = await openFetch.get(
"https://api.escuelajs.co/api/v1/categories"
);
// res.data, res.status, res.headers, res.configAxios — familiar API; different transport defaults in the browser:
import axios from "axios";
const res = await axios.get(
"https://api.escuelajs.co/api/v1/categories"
);
// res.data, res.status, res.headers, res.configky — minimal API on top of fetch:
import ky from "ky";
const data = await ky
.get("https://api.escuelajs.co/api/v1/categories")
.json();- Shared configuration —
baseURL, headers, timeouts, andunwrapResponseonce percreateClientinstance. - Cross-cutting behavior — attach auth, tracing, feature flags, and error normalization via interceptors and middleware.
- Resilience — retry policies and caching strategies without rewriting every call site.
- Predictable errors — map HTTP and network failures to typed errors instead of ad-hoc
try/catchparsing.
openFetch targets teams that want those benefits while staying on fetch everywhere the platform already provides it.
- Getting started — install, default export,
createClient, first requests - HTTP methods — GET, POST, PUT, PATCH, DELETE,
request(), bodies and query params - React & Vue — hooks, composables, shared clients, RSC notes
- Configuration — full request config,
rawResponse, merge rules, helper exports - Features & request pipeline — full feature list, merge → dispatch diagrams, retry hooks
- Plugins & fluent API —
@hamdymohamedak/openfetch/plugins,@hamdymohamedak/openfetch/sugar - Interceptors & middleware — execution order,
dispatchinternals,use(), custom middleware - Retry & cache — retry budgets, idempotency,
createCacheMiddleware, TTL / SWR - Errors & security —
OpenFetchError, codes, guards, safe logging,assertSafeHttpUrl - AI assistants & skills — concise API guidance for models;
SKILL.mdskill bundle and skills.sh / Agent Skills format
| Export | Role |
|---|---|
| default | Pre-built createClient() instance |
createClient / create |
New client with optional initialDefaults |
createFluentClient |
Callable fluent URL chains (from /sugar) |
retry, timeout, hooks, debug, strictFetch |
Middleware plugins (from /plugins) |
OpenFetchError, isOpenFetchError, isHTTPError, isTimeoutError |
Typed errors + guards |
SchemaValidationError, isSchemaValidationError |
Standard Schema failures on JSON |
OpenFetchForceRetry, isOpenFetchForceRetry |
Force another retry attempt from onAfterResponse |
| Standard Schema types | StandardSchemaV1, StandardSchemaV1InferOutput, … |
InterceptorManager |
Low-level interceptor stack |
createRetryMiddleware |
Retry middleware factory |
MemoryCacheStore, createCacheMiddleware, appendCacheKeyVaryHeaders |
In-memory cache |
maskHeaderValues, cloneResponse, idempotency helpers |
Logging and retry ergonomics |
| Types | OpenFetchConfig, OpenFetchResponse, Middleware, OpenFetchClient, etc. |
assertSafeHttpUrl |
Optional SSRF-style guard for literal IP/localhost in URLs |
Node.js 18+ or any runtime with fetch and AbortController.
- GitHub: openfetch-js/OpenFetch
- npm: @hamdymohamedak/openfetch
Browse all translations.