Table of Contents

**@arolariu/website**


@arolariu/website / sites/arolariu.ro/src/lib/utils.server / fetchWithTimeout

Function: fetchWithTimeout()

fetchWithTimeout(url, options, timeoutMs): Promise<Response>

Defined in: lib/utils.server.ts:156

Performs a fetch request with timeout support. Wraps the native fetch with AbortController for timeout handling.

Parameters

url

string

The URL to fetch

options

RequestInit = {}

Fetch options (headers, method, body, etc.)

timeoutMs

number = DEFAULT_FETCH_TIMEOUT

Timeout in milliseconds (default: 30 seconds)

Returns

Promise<Response>

Promise resolving to the Response object

Throws

When request times out or network fails

Example

const response = await fetchWithTimeout(
  `${API_URL}/invoices`,
  { headers: { Authorization: `Bearer ${token}` } },
  15000 // 15 second timeout
);