RequestOptions¶
RequestOptions describes one specific call. It should not copy the whole global configuration.
| Option | Default | Effect | Use when | Avoid if |
|---|---|---|---|---|
query |
{} |
Serializes string, number, and boolean values; ignores null and undefined. |
Pagination, filters, sort, simple flags. | Nested objects without a backend-documented format. |
headers |
{} |
Merged after defaults.headers; overrides matching names. |
If-Match, Prefer, X-Request-Source. |
Global auth headers: use auth or noAuth. |
json |
undefined |
Stringifies JSON and adds content-type and accept when absent. |
DTOs, commands, classic API payloads. | With body in the same request. |
body |
undefined |
Passed raw to fetch. |
FormData, Blob, ArrayBuffer, URLSearchParams. |
Plain JS object that should go through json. |
signal |
undefined |
Combines external cancellation with the internal timeout. | Destroyed Angular route, replaced search, cancellable action. | Already aborted signal. |
timeoutMs |
defaults.timeoutMs |
Overrides timeout for this call. | Long export or short search. | Hiding a slow endpoint without follow-up. |
cache |
No cache | Enables cache read/write for GET only. |
Lists, reference data, stable details. | Mutations or sensitive data. |
dataSchema |
No runtime schema | Validates data after parsing. |
Critical boundaries: permissions, payment, remote config. | Confusing TypeScript types with runtime validation. |
notifier |
Client notifier | Replaces the global notifier for this call. | Silent zone or critical endpoint. | Mixing policies with no visible reason. |
noAuth |
false |
Disables auth and refresh for the request. | Login, refresh, health, public assets. | Bypassing a 401 on a protected route. |
idempotencyKey |
undefined |
Identifies a replayable mutation. | Creation, payment, sensitive operation, double click. | Generating a new key for each retry of the same operation. |
Cache + Validation Example¶
const result = await api.get<User[]>("/users", {
query: { page: 1, active: true },
cache: {
ttlMs: 60_000,
tags: ["users"],
policy: "networkFirst"
},
dataSchema: userListSchema
});
Cache and HTTP methods
HTTP Guardian cache is a read optimization. Setting cache on POST, PUT, PATCH, or DELETE does not turn the mutation into application storage.