IRequestOptions Interface
The options bag passed to RequestProvider.registerRequest() to configure individual HTTP calls. All fields are optional — only set what you need to override the request defaults.
Usage Examples
Pass options as the second argument to registerRequest.
TypeScript
import { RequestProvider } from '@katlux/providers/request'
import type { IRequestOptions } from '@katlux/providers'
const rp = new RequestProvider()
// 1. Simple GET with query params
const users = await rp.registerRequest('/api/users', {
query: { active: true, role: 'admin' }
})
// 2. POST with body
const newUser = await rp.registerRequest('/api/users', {
method: 'POST',
body: { name: 'Alice', role: 'admin' }
})
// 3. DELETE request
await rp.registerRequest('/api/users', {
method: 'DELETE',
body: { id: [1, 2, 3] }
})
// 4. GET with caching and deduplication
const cached = await rp.registerRequest('/api/config', {
cacheStrategy: 'Memory',
lifetime: 60000, // cache for 1 minute
deduplicate: true // ignore concurrent duplicate calls
})
// 5. Force fresh data, overriding cache
const fresh = await rp.registerRequest('/api/config', {
disableCache: true
})
// 6. Custom headers (e.g. auth token)
const secure = await rp.registerRequest('/api/admin/report', {
headers: { 'X-Custom-Header': 'my-value' }
})Properties
All properties are optional.
| Property | Type | Default | Description |
|---|---|---|---|
| method | 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'GET' | HTTP method for the request. |
| body | any | — | Request body. Automatically serialized to JSON. |
| headers | Record<string, string> | — | Additional HTTP headers merged with the defaults. |
| query | Record<string, any> | — | URL query parameters appended to the request URL. |
| deduplicate | boolean | true | When true, concurrent identical requests share a single in-flight promise instead of making multiple network calls. |
| disableCache | boolean | false | When true, skips reading from and writing to the cache, guaranteeing a fresh network call. |
| cacheStrategy | ECacheStrategy | — | Per-request cache backend override. Takes precedence over the provider-level setting. |
| lifetime | number | 0 | Cache TTL in milliseconds for this specific request. 0 means no expiry. |
| key | string | — | Explicit cache key. Defaults to the request URL + serialized query if omitted. |
| cacheKey | string | — | Namespace / context key used by shared cache storage (e.g. to group entries for easy bulk invalidation). |