refactor: improve async data fetching in load functions

This commit is contained in:
maxid
2025-12-21 16:16:12 +01:00
parent 9187617530
commit 4b7d5eea54
2 changed files with 8 additions and 8 deletions

View File

@@ -2,17 +2,17 @@ import type { LayoutLoad } from './$types';
import client from '$lib/api';
export const load: LayoutLoad = async ({ params, fetch }) => {
const show = await client.GET('/api/v1/tv/shows/{show_id}', {
const show = client.GET('/api/v1/tv/shows/{show_id}', {
fetch: fetch,
params: { path: { show_id: params.showId } }
});
const torrents = await client.GET('/api/v1/tv/shows/{show_id}/torrents', {
const torrents = client.GET('/api/v1/tv/shows/{show_id}/torrents', {
fetch: fetch,
params: { path: { show_id: params.showId } }
});
return {
showData: show.data,
torrentsData: torrents.data
showData: await show.then((x) => x.data),
torrentsData: await torrents.then((x) => x.data)
};
};

View File

@@ -2,7 +2,7 @@ import type { PageLoad } from './$types';
import client from '$lib/api';
export const load: PageLoad = async ({ fetch, params }) => {
const season = await client.GET('/api/v1/tv/seasons/{season_id}', {
const season = client.GET('/api/v1/tv/seasons/{season_id}', {
fetch: fetch,
params: {
path: {
@@ -10,7 +10,7 @@ export const load: PageLoad = async ({ fetch, params }) => {
}
}
});
const seasonFiles = await client.GET('/api/v1/tv/seasons/{season_id}/files', {
const seasonFiles = client.GET('/api/v1/tv/seasons/{season_id}/files', {
fetch: fetch,
params: {
path: {
@@ -19,7 +19,7 @@ export const load: PageLoad = async ({ fetch, params }) => {
}
});
return {
files: seasonFiles.data,
season: season.data
files: await seasonFiles.then((x) => x.data),
season: await season.then((x) => x.data)
};
};