Querying data from Prisma
Answered
Palomino posted this in #help-forum
PalominoOP
Hi, so I'm trying to query data from prisma but nextjs keeps showing an undefined result. Can anyone help?
Answered by Giant panda
async function Page() {
const users = await prisma.user.findMany();
// ...
}9 Replies
Giant panda
Are you using the pages or the app router?
@Giant panda Are you using the pages or the app router?
PalominoOP
App router
Giant panda
getStaticProps isn't available in app router, it's a pages router thing
You just fetch/query directly in your component
Giant panda
async function Page() {
const users = await prisma.user.findMany();
// ...
}Answer
PalominoOP
ah I see
okay, let me try that
@Giant panda tsx
async function Page() {
const users = await prisma.user.findMany();
// ...
}
PalominoOP
And it worked. Thanks