Skip to main content
zerotal

Documentation


Documentation / @zerotal/client / index / RequestInterceptor

Type Alias: RequestInterceptor

RequestInterceptor = (config) => RequestConfig | Promise<RequestConfig>

Defined in: client/src/ApiClient.ts:44

Called before every outgoing request. Must return the (possibly mutated) RequestConfig.

Parameters

config

RequestConfig

Returns

RequestConfig | Promise<RequestConfig>

Example

onRequest: async (cfg) => ({
  ...cfg,
  headers: { ...cfg.headers, Authorization: `Bearer ${await tokenStore.get()}` },
})