[**Documentation**](../../../README)

***

[Documentation](../../../README) / [zerotal](../../README) / [client](../README) / RequestInterceptor

# Type Alias: RequestInterceptor

> **RequestInterceptor** = (`config`) => [`RequestConfig`](../interfaces/RequestConfig) \| `Promise`\<[`RequestConfig`](../interfaces/RequestConfig)\>

Defined in: [packages/client/src/ApiClient.ts:44](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/client/src/ApiClient.ts#L44)

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

## Parameters

### config

[`RequestConfig`](../interfaces/RequestConfig)

## Returns

[`RequestConfig`](../interfaces/RequestConfig) \| `Promise`\<[`RequestConfig`](../interfaces/RequestConfig)\>

## Example

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