diff --git a/ui/app/api/news/[id]/router.ts b/ui/app/api/news/[id]/router.ts new file mode 100644 index 0000000..02d52a2 --- /dev/null +++ b/ui/app/api/news/[id]/router.ts @@ -0,0 +1,12 @@ +import { NextResponse } from "next/server"; +import { fetchNewsData } from "../../../../lib/fetchNewsData"; + +export async function GET(request: Request, { params }: { params: { id: string } }) { + const newsData = await fetchNewsData(params.id); + + if (!newsData) { + return NextResponse.json({ error: "News not found" }, { status: 404 }); + } + + return NextResponse.json(newsData); +} diff --git a/ui/app/news/[id]/page.tsx b/ui/app/news/[id]/page.tsx index b9b0a3c..a98b18f 100644 --- a/ui/app/news/[id]/page.tsx +++ b/ui/app/news/[id]/page.tsx @@ -5,7 +5,7 @@ export default async function NewsPage({ params }: { params: { id: string } }) { const newsData = await fetchNewsData(params.id); if (!newsData) { - return