replace all occurrences of fetch with openapi-fetch in routes

This commit is contained in:
maxDorninger
2025-08-29 21:06:59 +02:00
parent 5a71246623
commit ded9503169
21 changed files with 1043 additions and 1358 deletions

View File

@@ -1,34 +1,11 @@
import { env } from '$env/dynamic/public';
import type { LayoutLoad } from './$types';
import client from "$lib/api";
const apiUrl = env.PUBLIC_API_URL;
export const load: LayoutLoad = async ({ fetch }) => {
try {
const requests = await fetch(`${apiUrl}/tv/seasons/requests`, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
},
credentials: 'include'
});
if (!requests.ok) {
console.error(`Failed to fetch season requests ${requests.statusText}`);
return {
requestsData: null
};
}
const requestsData = await requests.json();
console.log('Fetched season requests:', requestsData);
return {
requestsData: requestsData
};
} catch (error) {
console.error('Error fetching season requests:', error);
return {
requestsData: null
};
}
const { data, error } = await client.GET('/api/v1/tv/seasons/requests', { fetch: fetch });
return {
requestsData: data
};
};