1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-20 14:37:43 +01:00

Return values instead of promise

Co-authored-by: William Oldham <github@binaryoverload.co.uk>
This commit is contained in:
Megh Rathod 2024-04-14 15:14:14 +05:30 committed by GitHub
parent 76d906c95a
commit 0e3f82df30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -156,10 +156,10 @@ 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");
let res: Promise<T>; let res: T;
try { try {
res = await mwFetch<any>(encodeURI(url), { res = await mwFetch<T>(encodeURI(url), {
headers, headers,
baseURL, baseURL,
params: { params: {
@ -170,7 +170,7 @@ async function get<T>(url: string, params?: object): Promise<T> {
} catch (err) { } catch (err) {
if (baseURL !== otherUrl) { if (baseURL !== otherUrl) {
baseURL = otherUrl; baseURL = otherUrl;
res = await mwFetch<any>(encodeURI(url), { res = await mwFetch<T>(encodeURI(url), {
headers, headers,
baseURL, baseURL,
params: { params: {