mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-26 18:55:44 +02:00
replace all occurrences of fetch with openapi-fetch in routes
This commit is contained in:
@@ -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
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user