add json placeholder link for test
This commit is contained in:
parent
2bbd0dd602
commit
32ee6d06f4
|
|
@ -0,0 +1,18 @@
|
|||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params: { id } }: { params: { id: string } },
|
||||
) {
|
||||
if (!id) throw new Error("Where is id...");
|
||||
|
||||
const res = await fetch(`https://jsonplaceholder.typicode.com/todos/${id}`);
|
||||
|
||||
if (!res.ok) {
|
||||
return new NextResponse("{}");
|
||||
}
|
||||
|
||||
const body = await res.json();
|
||||
|
||||
return new NextResponse(JSON.stringify(body, null, 2));
|
||||
}
|
||||
Loading…
Reference in New Issue