add json placeholder link for test

This commit is contained in:
sjwie 2024-02-16 10:56:06 +09:00
parent 2bbd0dd602
commit 32ee6d06f4
1 changed files with 18 additions and 0 deletions

View File

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