Any HTTP client works: implement FetcherFunction and pass it through. Useful for adding retries, logging, header injection, or wrapping an unusual transport.
import { constructSimpleSDK, type FetcherFunction } from "@velora-dex/sdk";const customFetcher: FetcherFunction = async (options) => { // requestParams may include AbortSignal; honor it for cancellation const res = await myHttpClient(options.url, { method: options.method, headers: options.headers, body: options.method === "POST" ? options.data : undefined, signal: options.requestParams?.signal, }); if (!res.ok) throw new Error(`HTTP ${res.status}`); return res.body;};const sdk = constructSimpleSDK({ chainId: 1, fetcher: customFetcher,});
For richer error semantics, throw a FetcherError and the SDK will re-throw it untouched so calling code can isFetcherError(err) and inspect the response.