Skip to Content

Coming from axios or ky

Map what you know from axios or ky to Effetch.

If you've used axios or ky, most of what you know has a counterpart in Effetch. The following table maps what you know from axios and ky to Effetch:

axios or kyEffetch
axios.create, ky.createFetch.Service, or Fetch.make in a script
ky.extend, a client per API versionA second Fetch.Service from { ...Api.config, baseUrl } (see Derive a client)
baseURL, prefixUrlbaseUrl, a string or an Effect such as a Config
params, searchParamsquery, a plain object, or typed by an endpoint's query schema
Interceptors, hooks.beforeRequest and hooks.afterResponseA plugin's onRequest and onResponse
hooks.beforeErrorEffect.mapError on the call. A plugin's onError sees errors but can't change them
retry, timeoutThe retry and timeout plugins, which a call can turn off or adjust
ky's totalTimeoutretry({ budget }), or Effect.timeout around a call
AbortController, signalInterruption: Fiber.interrupt, Effect.race, Effect.timeout. An interrupted call aborts its request
validateStatus, throwHttpErrors: falseEffect.catchTag("HttpError", …), statusErrors, or Fetch.catchStatus and Fetch.optional
error.response.data, ky's HTTPError bodyHttpError.body, decoded with defaultError or the call's error schema
ky.get(url).json<T>(), axios.get<T>(url)api.get(path, { output: Schema }): the body is checked, not cast
responseType: "text" or "arraybuffer"output: Fetch.text() or Fetch.bytes() (see Read text or bytes)
Reading the status and headers with the dataresponseMode: "decoded-and-response" (see Read the body and the response)
responseType: "stream", onDownloadProgress for eventsapi.sse and api.ndjson
A FormData body built by handinput: Fetch.multipart(schema), a typed body sent as a form (see Upload files)
The fetch option or an adapter in testsFetchTest, or any HttpClient layer