send response last

This commit is contained in:
Thomas Ruoff
2022-07-06 22:08:35 +02:00
parent 1e9c0dfac9
commit 3a4a4ad0b0

View File

@@ -20,7 +20,6 @@ export default async function userHandler(
case 'POST':
try {
booking = await createBooking(req.body)
res.status(200).json(booking)
} catch (e) {
if (e instanceof Error.ValidationError) {
res.status(400).json({ message: e.message, errors: e.errors })
@@ -42,6 +41,7 @@ export default async function userHandler(
`send booking ${booking.uuid} received to {booking.email}`,
booking
)
res.status(200).json(booking)
break
default:
res.setHeader('Allow', ['POST'])