Error thrown when a request times out

Thrown by the timeout middleware when a request exceeds the configured timeout duration. Includes the timeout value that was exceeded.

Example

import { createFej, createTimeoutMiddleware, FejTimeoutError } from 'fej';

const api = createFej();
api.use('timeout', createTimeoutMiddleware({ timeout: 5000 }));

try {
await api.fej('/api/slow-endpoint');
} catch (error) {
if (error instanceof FejTimeoutError) {
console.error(`Request timed out after ${error.timeout}ms`);
}
}

Hierarchy (view full)

Constructors

Properties

originalError?: Error
context?: FejContext
statusCode?: number
timeout: number