Skip to content
This repository was archived by the owner on Jun 26, 2025. It is now read-only.

Commit a428729

Browse files
committed
fix: refactor fetchWithTimeout to use app's request method and simplify options
1 parent 956908e commit a428729

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

main.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,9 @@ class CssSnippetStoreModal extends Modal {
322322
}
323323
}
324324

325-
function fetchWithTimeout(resource: RequestInfo, options: RequestInit = {}, timeout = 10000): Promise<Response> {
325+
function fetchWithTimeout(resource: RequestInfo, timeout = 10000): Promise<Response> {
326326
return Promise.race([
327-
fetch(resource, options),
327+
this.app.request.requestUrl(resource),
328328
new Promise<Response>((_, reject) => setTimeout(() => reject(new Error("Request timed out")), timeout))
329329
]);
330330
}
@@ -334,11 +334,10 @@ export async function isOnline(timeout = 3000): Promise<boolean> {
334334
const controller = new AbortController();
335335
const id = setTimeout(() => controller.abort(), timeout);
336336

337-
await fetch("https://ping.archlinux.org", {
337+
await this.app.request.requestUrl({
338+
url: "https://ping.archlinux.org",
338339
method: "GET",
339-
mode: "no-cors",
340-
signal: controller.signal,
341-
cache: "no-store"
340+
cache: "no-cache"
342341
});
343342
clearTimeout(id);
344343
return true;

0 commit comments

Comments
 (0)