mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-20 14:37:43 +01:00
fix: use AbortSignal.timeout instead of setTimeout
Signed-off-by: Megh Rathod <me@meghrathod.dev>
This commit is contained in:
parent
1ec51699d1
commit
76d906c95a
1 changed files with 1 additions and 9 deletions
|
@ -156,13 +156,6 @@ const headers = {
|
|||
async function get<T>(url: string, params?: object): Promise<T> {
|
||||
if (!apiKey) throw new Error("TMDB API key not set");
|
||||
|
||||
const controller = new AbortController();
|
||||
const { signal } = controller;
|
||||
|
||||
const timeoutId =
|
||||
baseURL === otherUrl
|
||||
? setTimeout(() => controller.abort(), 15000)
|
||||
: setTimeout(() => controller.abort(), 3000);
|
||||
let res: Promise<T>;
|
||||
|
||||
try {
|
||||
|
@ -172,9 +165,8 @@ async function get<T>(url: string, params?: object): Promise<T> {
|
|||
params: {
|
||||
...params,
|
||||
},
|
||||
signal,
|
||||
signal: AbortSignal.timeout(baseURL !== otherUrl ? 5000 : 30000),
|
||||
});
|
||||
clearTimeout(timeoutId);
|
||||
} catch (err) {
|
||||
if (baseURL !== otherUrl) {
|
||||
baseURL = otherUrl;
|
||||
|
|
Loading…
Reference in a new issue