This version (v0.7) has not been published to npm yet.
Skip to content

Reference / @getenginex/sdk / EnginexClientHooks

EnginexClientHooks ​

Client observability hooks: they never receive headers, tokens or body (see RequestHookContext). Called via safeCall: a hook that throws does not affect the request or break other hooks. Internal SDK requests (session renewal, POST /auth/refresh) never fire any of these three hooks — only the public request that originated the 401 is reported.

Properties ​

onError? ​

optional onError?: (error, ctx) => void

Called exactly once per public call that fails — never per attempt —, with the final EnginexError: the same object the method's Promise rejects with. An error that is part of the method's normal flow (e.g. 2FA_REQUIRED in login, which becomes the return value { status: '2fa_required' }) or that the method swallows by contract (e.g. logout, which never rejects) does not fire onError.

Parameters ​

error ​

EnginexError

ctx ​

RequestHookContext

Returns ​

void


onRequest? ​

optional onRequest?: (ctx) => void

Called before each attempt (the initial one and the retry after a renewed 401).

Parameters ​

ctx ​

RequestHookContext

Returns ​

void


onResponse? ​

optional onResponse?: (ctx) => void

Called after each response received (even on an HTTP error).

Parameters ​

ctx ​

ResponseHookContext

Returns ​

void