Files
link-free/src/api/data/updateData.ts
2021-12-23 18:02:47 -03:00

24 lines
562 B
TypeScript

import { prisma } from 'services/prisma'
import { ExceptionError } from 'utils/error'
import type { NextApiRequest, NextApiResponse } from 'next'
export async function updateData(req: NextApiRequest, res: NextApiResponse) {
const { data } = req.body
if (!data) {
throw new ExceptionError('No data provided')
}
try {
const response = await prisma.data.update({
where: { id: 1 },
data: { data: JSON.stringify(req.body.data) }
})
res.status(200).json(response)
} catch (err: any) {
throw new ExceptionError(err)
}
}