diff --git a/src/utils/api.ts b/src/utils/api.ts index 53326d6..b244e06 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -1,9 +1,25 @@ +/** + * API Utility Functions + * Provides enhanced fetch functionality with timeout support + */ + import { handleError, createAPIError } from './errorHandling'; +/** + * Extended request options with timeout support + */ interface RequestOptions extends RequestInit { + /** Request timeout in milliseconds (default: 8000ms) */ timeout?: number; } +/** + * Fetch with automatic timeout and error handling + * @param resource - URL or resource to fetch + * @param options - Request options including optional timeout + * @returns Promise resolving to the fetch Response + * @throws {Error} On timeout, network error, or HTTP error status + */ export async function fetchWithTimeout( resource: string, options: RequestOptions = {}