meal_planner/server/api/recipes.get.ts
2024-12-15 01:18:08 +01:00

13 lines
358 B
TypeScript

import { parseRecipeData } from "~/utils/recipes";
import type { Meal } from "~/types/recipe";
export default defineEventHandler(async (_event) => {
const { apiUrl } = useRuntimeConfig();
const data = await $fetch<{ meals: Meal[] }>(
new URL("random.php", apiUrl).toString(),
);
const recipes = parseRecipeData(data);
return recipes[0];
});