cosette/server/api/comment.post.js

12 lines
318 B
JavaScript
Raw Permalink Normal View History

2022-08-12 18:23:03 +02:00
import { addComment } from '../controller'
import { useBody } from 'h3'
export default defineEventHandler(async (event) => {
try {
const body = await useBody(event)
2022-08-13 11:56:59 +02:00
const comment = addComment(body)
return { success: true, comment }
2022-08-12 18:23:03 +02:00
} catch (e) {
return { success: false, reason: e.message }
}
})