send mail

This commit is contained in:
Thomas Ruoff
2020-08-18 00:22:03 +02:00
parent 70d78427b1
commit d86f438f80
3 changed files with 50 additions and 5 deletions

View File

@@ -1,14 +1,18 @@
import { createBooking } from '../../db/index'
import { Error } from 'mongoose'
import { sendReceivedBookingMail } from '../../helpers/mail'
export default async function userHandler(req, res) {
const { method } = req
let booking
switch (method) {
case 'POST':
try {
const data = await createBooking(req.body)
res.status(200).json(data)
booking = await createBooking(req.body)
res.status(200).json(booking)
} catch (e) {
console.error(e)
@@ -18,6 +22,9 @@ export default async function userHandler(req, res) {
}
res.status(500).end(`Internal Server Error...Guru is meditating...`)
}
await sendReceivedBookingMail(booking)
console.log('sent receivedBookingMail')
break
default:
res.setHeader('Allow', ['POST'])