Files
Open-Assistant/website/src/pages/api/username.tsx
T
2023-01-03 15:27:37 +01:00

21 lines
485 B
TypeScript

import { getSession } from "next-auth/react";
import prisma from "../../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 });
}