RESTHooks
Defined in: packages/rest/src/index.ts:205
Lightweight callback hooks for REST request lifecycle events.
All callbacks are optional. They are dispatched in isolation from the request path (deferred to a microtask, and any thrown error is swallowed), so a hook cannot break or reject a request. Even so, hooks must be fast and non-blocking: heavy synchronous work in a hook still steals event-loop time from in-flight requests. Offload anything expensive to your own queue.
Methods
Section titled “Methods”onRateLimit()?
Section titled “onRateLimit()?”
optionalonRateLimit(ctx):void
Defined in: packages/rest/src/index.ts:211
Called when a rate limit is encountered and the client is about to wait.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
onRequest()?
Section titled “onRequest()?”
optionalonRequest(ctx):void
Defined in: packages/rest/src/index.ts:207
Called just before every HTTP attempt.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
onResponse()?
Section titled “onResponse()?”
optionalonResponse(ctx):void
Defined in: packages/rest/src/index.ts:209
Called after a successful or failed response is received.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
onRetry()?
Section titled “onRetry()?”
optionalonRetry(ctx):void
Defined in: packages/rest/src/index.ts:213
Called when a failed request is about to be retried.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void