feat(recipes): load recipe list from API in page server
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
21
frontend/src/routes/(app)/recipes/+page.server.ts
Normal file
21
frontend/src/routes/(app)/recipes/+page.server.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
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
|
||||
}))
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user