Methods
A client has get, post, put, patch and delete. Each takes a path and an options object and returns the parsed body.
ts
await api.get<User>("/users/42");await api.put<User>("/users/42", { body: { name: "Ada" } });await api.delete("/users/42");Query strings
Pass query as an object. Arrays repeat the key, undefined values are left out, so optional filters need no if.
ts
await api.get("/orders", { query: { status: ["paid", "shipped"], after: cursor, limit: 50 },});// GET /orders?status=paid&status=shipped&limit=50Bodies
Plain objects are sent as JSON with the matching Content-Type. FormData, Blob and URLSearchParams pass through untouched.
Deduplication
Two GETs to the same URL while the first is in flight share one request. Both callers get the same parsed body.
Don't mutate shared results
Deduplicated callers receive the same object. Copy it before changing it, or turn deduplication off with
dedupe: false.