Skip to Content
🎉 New release with new features and improvements! V0.0.5 Release →
DocumentationsBsh EngineSDKInterceptorsOverview

Interceptors Overview

Interceptors allow you to modify requests and responses, or handle errors globally. They are executed in the order they are added.

There are three types of interceptors:

  1. Pre-Interceptors: Modify requests before they’re sent
  2. Post-Interceptors: Modify responses after they’re received
  3. Error Interceptors: Handle errors globally

Interceptors are useful for:

  • Adding custom headers to all requests
  • Logging requests and responses
  • Transforming data
  • Centralized error handling
  • …

Bypassing Interceptors

You can bypass interceptors for a specific request by using the byPass option in the request parameters.

const response = await bshEngine.api.users.get({ id: '123', byPass: { interceptors: { pre: true, // Bypass pre-interceptors post: true, // Bypass post-interceptors error: true // Bypass error-interceptors } } });