import type { NextApiRequest, NextApiResponse } from 'next' import prisma from '../../../lib/prisma' import { getSession } from 'next-auth/react' // UPDATE /api/profile // Required fields in body: title export default async function handle(req: NextApiRequest, res: NextApiResponse) { const { bioValue } = req.body; const session = await getSession({ req }); if (req.method === "PUT") { if (session) { const updateUserProfil = await prisma.user.update({ where: { email: session.user.email }, data: { profile: { update: { bio: bioValue, }, }, } }) res.status(200).send({ result: updateUserProfil, message: 'Profiled updated !' }); } else { res.status(401).send({ message: 'Unauthorized' }) } } else { throw new Error( `The HTTP ${req.method} method is not supported at this route.` ); } }