Files
dkala-front/src/lib/helpers/fetchWithTimeout.ts
T
hamid zarghami c08b4ec023
deploy to danak / build_and_deploy (push) Has been cancelled
update glass + pattenr + ...
2026-07-07 14:48:33 +03:30

14 lines
333 B
TypeScript

const DEFAULT_TIMEOUT_MS = 5000;
export async function fetchWithTimeout(
url: string,
options: RequestInit & { timeoutMs?: number } = {},
): Promise<Response> {
const { timeoutMs = DEFAULT_TIMEOUT_MS, ...fetchOptions } = options;
return fetch(url, {
...fetchOptions,
signal: AbortSignal.timeout(timeoutMs),
});
}