Plugins
Retry
Automatic retry on failure
The retry plugin automatically retries failed requests with configurable attempts and delay.
Installation
npm install @spoosh/plugin-retryUsage
import { Spoosh } from "@spoosh/core";
import { retryPlugin } from "@spoosh/plugin-retry";
const client = new Spoosh<ApiSchema, Error>("/api").use([
retryPlugin({ retries: 3, retryDelay: 1000 }),
]);Per-Request Override
// More retries for critical requests
injectRead((api) => api("important").GET(), { retries: 5, retryDelay: 2000 });
// Disable retries for specific requests
injectRead((api) => api("health").GET(), { retries: false });Options
Plugin Config
| Option | Type | Default | Description |
|---|---|---|---|
retries | number | false | 3 | Number of retry attempts. Set to false to disable. |
retryDelay | number | 1000 | Delay between retries in milliseconds |
Per-Request Options
| Option | Type | Description |
|---|---|---|
retries | number | false | Override retry attempts for this request |
retryDelay | number | Override retry delay for this request |