mirror of
https://github.com/feeddeck/feeddeck.git
synced 2026-05-23 07:21:10 -05:00
Format the Deno code via "deno fmt" to use the defined code style from the "deno.json" file.
16 lines
478 B
TypeScript
16 lines
478 B
TypeScript
/**
|
|
* `fetchWithTimeout` is a wrapper around `fetch` that adds a timeout. If the
|
|
* request takes longer than the timeout, the request will be aborted.
|
|
*/
|
|
export const fetchWithTimeout = async (
|
|
url: string,
|
|
options: RequestInit,
|
|
timeout: number,
|
|
) => {
|
|
const controller = new AbortController();
|
|
const id = setTimeout(() => controller.abort(), timeout);
|
|
const res = await fetch(url, { ...options, signal: controller.signal });
|
|
clearTimeout(id);
|
|
return res;
|
|
};
|