rsnext/examples/with-redux/app/api/counter/route.ts

16 lines
429 B
TypeScript

import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";
interface Context {
params: undefined;
}
export async function POST(request: NextRequest, context: Context) {
const body: { amount: number } = await request.json();
const { amount = 1 } = body;
// simulate IO latency
await new Promise((resolve) => setTimeout(resolve, 500));
return NextResponse.json({ data: amount });
}