mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Updated to use AbortController pattern
This commit is contained in:
@@ -35,12 +35,19 @@ export async function sendPushover(
|
|||||||
body.expire = 3600;
|
body.expire = 3600;
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await fetch("https://api.pushover.net/1/messages.json", {
|
const controller = new AbortController();
|
||||||
method: "POST",
|
const timeout = setTimeout(() => controller.abort(), 10_000);
|
||||||
headers: {"Content-Type": "application/json"},
|
let res: Response;
|
||||||
body: JSON.stringify(body),
|
try {
|
||||||
signal: AbortSignal.timeout(10_000),
|
res = await fetch("https://api.pushover.net/1/messages.json", {
|
||||||
});
|
method: "POST",
|
||||||
|
headers: {"Content-Type": "application/json"},
|
||||||
|
body: JSON.stringify(body),
|
||||||
|
signal: controller.signal,
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
const json = await res.json().catch(() => null);
|
const json = await res.json().catch(() => null);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user