Per-Call Overrides
Override middleware options on individual requests
Overview
The retry and timeout middlewares accept default options at client creation time. You can override those defaults for a single call by passing retry or timeout in the call arguments:
// Global: 3 retries, 5s timeout
const client = createClient(api, {
middlewares: [
retry({ limit: 3 }),
timeout({ timeout: 5000 }),
],
});
// This specific call: 5 retries, 30s timeout
const report = await client.reports.generate({
retry: { limit: 5 },
timeout: 30000,
});
// This call: no retries
const data = await client.analytics.realtime({
retry: { limit: 0 },
});Supported Overrides
| Key | Type | Affects |
|---|---|---|
retry | Partial<RetryOptions> | Retry middleware |
timeout | number | Timeout middleware |