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': case 'POST':
try { try {
booking = await createBooking(req.body) booking = await createBooking(req.body)
res.status(200).json(booking)
} catch (e) { } catch (e) {
if (e instanceof Error.ValidationError) { if (e instanceof Error.ValidationError) {
res.status(400).json({ message: e.message, errors: e.errors }) 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}`, `send booking ${booking.uuid} received to {booking.email}`,
booking booking
) )
res.status(200).json(booking)
break break
default: default:
res.setHeader('Allow', ['POST']) res.setHeader('Allow', ['POST'])