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?
optionalonError?: (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
ctx
Returns
void
onRequest?
optionalonRequest?: (ctx) =>void
Called before each attempt (the initial one and the retry after a renewed 401).
Parameters
ctx
Returns
void
onResponse?
optionalonResponse?: (ctx) =>void
Called after each response received (even on an HTTP error).
Parameters
ctx
Returns
void