-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix styling, add catch errors, add loading
- Loading branch information
Showing
3 changed files
with
49 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
import { NextApiResponse } from 'next'; | ||
import type { NextApiRequest, NextApiResponse } from 'next'; | ||
import { prisma } from '../../../utils/prisma'; | ||
|
||
export default async function handler(req, res: NextApiResponse) { | ||
const users = await prisma.user.findMany(); | ||
res.status(200).json(users); | ||
export default async function handler( | ||
req: NextApiRequest, | ||
res: NextApiResponse | ||
) { | ||
try { | ||
const users = await prisma.user.findMany(); | ||
res.status(200).json(users); | ||
} catch (error) { | ||
console.error('Error fetching users:', error); | ||
res.status(500).json({ error: 'Internal server error' }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters