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