|
|
@ -156,13 +156,6 @@ const headers = { |
|
|
|
async function get<T>(url: string, params?: object): Promise<T> { |
|
|
|
async function get<T>(url: string, params?: object): Promise<T> { |
|
|
|
if (!apiKey) throw new Error("TMDB API key not set"); |
|
|
|
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>; |
|
|
|
let res: Promise<T>; |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
@ -172,9 +165,8 @@ async function get<T>(url: string, params?: object): Promise<T> { |
|
|
|
params: { |
|
|
|
params: { |
|
|
|
...params, |
|
|
|
...params, |
|
|
|
}, |
|
|
|
}, |
|
|
|
signal, |
|
|
|
signal: AbortSignal.timeout(baseURL !== otherUrl ? 5000 : 30000), |
|
|
|
}); |
|
|
|
}); |
|
|
|
clearTimeout(timeoutId); |
|
|
|
|
|
|
|
} catch (err) { |
|
|
|
} catch (err) { |
|
|
|
if (baseURL !== otherUrl) { |
|
|
|
if (baseURL !== otherUrl) { |
|
|
|
baseURL = otherUrl; |
|
|
|
baseURL = otherUrl; |
|
|
|