22 lines
477 B
TypeScript
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
|
|
}))
|
|
};
|
|
};
|