Skip to main content

setOtelOnUnauthorized

Datalayer Core


Datalayer Core / setOtelOnUnauthorized

Function: setOtelOnUnauthorized()

setOtelOnUnauthorized(cb): void

Defined in: src/otel/hooks/index.ts:33

Register a callback invoked whenever an OTEL API call receives a 401 Unauthorized response. Typically used to clear auth state (i.e. log the user out) when the token has expired.

Pass null to unregister.

Parameters

cb

(() => void) | null

Returns

void

Example

import { setOtelOnUnauthorized } from '@datalayer/core/lib/otel';
setOtelOnUnauthorized(() => authStore.getState().clearAuth());