Skip to main content

Interceptors

Interceptors let you hook into the request/response lifecycle to add logging, inject headers, transform data, or handle errors globally. The API is inspired by Axios interceptors.

Overview

The SDK exposes three interceptor chains:

Request Interceptors

Add custom headers or log outgoing requests:

RequestConfig Shape

Response Interceptors

Transform or log successful responses:

ResponseData Shape

Error Interceptors

Handle errors globally before they reach your catch blocks:

Managing Interceptors

Remove an Interceptor

The use() method returns an ID you can pass to eject():

Clear All Interceptors

Check If Any Are Registered

Execution Order

Interceptors execute in the order they are registered:

Async Interceptors

Interceptors can be async. Each interceptor waits for the previous one to resolve: