Configuration
References to the same client share configuration. Create a private client for this site’s demo API.
import { Http, envelope } from "fetchzen";const api = Http.create(`${location.origin}/api/examples/`, { cache: false, secure: false, preset: envelope,});const shared = api;api.configure({ params: { name: "Ada" } });const remove = shared.hook("request", () => { console.log("request"); });try { console.log(await shared.get("echo"));} finally { remove();}Ready. No request sent.
Result
Choose Run to see the response.
Event log
No events yet.
What to notice
Section titled “What to notice”shared is an alias, not an independent client. It sees updated defaults.
The hook returns a removal function. Each run uses a private client, without global credentials or cross-user state.