Files
Open-Assistant/website/src/pages/api/username.tsx
T

21 lines
483 B
TypeScript

import { getSession } from "next-auth/react";
import prisma from "src/lib/prismadb";
// POST /api/post
// Required fields in body: title
// Optional fields in body: content
export default async function handle(req, res) {
const { username } = req.body;
const session = await getSession({ req });
const result = await prisma.user.update({
where: {
email: session.user.email,
},
data: {
name: username,
},
});
res.json({ name: result.name });
}