Files
mealprep/frontend/src/routes/(app)/recipes/+page.server.ts
2026-04-03 09:45:43 +02:00

22 lines
477 B
TypeScript

import type { PageServerLoad } from './$types';
import { apiClient } from '$lib/server/api';
export const load: PageServerLoad = async ({ fetch }) => {
const api = apiClient(fetch);
const { data, error } = await api.GET('/v1/recipes', {});
if (error || !data?.data) {
return { recipes: [] };
}
return {
recipes: data.data.map((r) => ({
id: r.id!,
name: r.name!,
cookTimeMin: r.cookTimeMin,
effort: r.effort,
heroImageUrl: r.heroImageUrl
}))
};
};