---
url: >-
  https://game-engine-io.github.io/enginex-frontend-sdk/reference/api/@getenginex/sdk/interfaces/EnginexClientHooks.md
---
[Reference](../../../index.md) / [@getenginex/sdk](../index.md) / EnginexClientHooks

# EnginexClientHooks

Client observability hooks: they never receive headers, tokens or body (see
[RequestHookContext](RequestHookContext.md)). 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](../classes/EnginexError.md): 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`](../classes/EnginexError.md)

##### ctx

[`RequestHookContext`](RequestHookContext.md)

#### Returns

`void`

***

### onRequest?

> `optional` **onRequest?**: (`ctx`) => `void`

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

#### Parameters

##### ctx

[`RequestHookContext`](RequestHookContext.md)

#### Returns

`void`

***

### onResponse?

> `optional` **onResponse?**: (`ctx`) => `void`

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

#### Parameters

##### ctx

[`ResponseHookContext`](ResponseHookContext.md)

#### Returns

`void`
