the following code is a simple and quick update. notice schema functions error property is same but it’s not error.errors it’s error.issues
you may see this error in your editor
Property ‘errors’ does not exist on type ‘ZodError<{ name: string; }>’.ts(2339)
export async function PUT(request: NextRequest, {params}: Params ) {
const body = await request.json() const validation = schema.safeParse(body)
if( !validation.success )
return NextResponse.json(validation.error.issues, {status: 400})
if(params.id > 10)
return NextResponse.json({error: 'user not found'}, {status: 404}) return NextResponse.json({id:1, name: body.name}, {status: 200})
}