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:
- Pre-Interceptors: Modify requests before they’re sent
- Post-Interceptors: Modify responses after they’re received
- 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
}
}
});