now can load local detail news

This commit is contained in:
Yifei Hu 2024-07-11 12:33:19 +08:00
parent 14294f8a14
commit deb82d38b8
3 changed files with 23 additions and 6 deletions

View file

@ -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);
}