34 lines
844 B
TypeScript
34 lines
844 B
TypeScript
import { NextApiRequest, NextApiResponse } from 'next'
|
|
|
|
import { internalServerError, success } from '../../lib/api-responses'
|
|
import { notion } from '../../lib/notion'
|
|
|
|
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
|
try {
|
|
const { email, message, inquiry } = JSON.parse(req.body)
|
|
await notion.pages.create({
|
|
parent: {
|
|
database_id: '03c225f0469d436db60bd1b225deffef' as string
|
|
},
|
|
properties: {
|
|
Email: {
|
|
email,
|
|
type: 'email'
|
|
},
|
|
Message: {
|
|
type: 'rich_text',
|
|
rich_text: [{ text: { content: message }, type: 'text' }]
|
|
},
|
|
'Type of inquiry': {
|
|
type: 'select',
|
|
select: { name: inquiry }
|
|
}
|
|
}
|
|
})
|
|
|
|
success(res)
|
|
} catch (error) {
|
|
internalServerError(res, error)
|
|
}
|
|
}
|