Data isn't showing on the page. I think I've done ...
# prisma-client
c
Data isn't showing on the page. I think I've done this correctly.
Copy code
export async function getServerSideProps({ params }) {
const users = await prisma.user.findMany({
  where: { 
    createdAt: new Date(),
    name: params.toString()
  }
})

return {
  props : { users }
}
}

export default function UserPage({users}){
  return (
    <>
      <Head>
      <title>{users.username}</title>
      </Head>
      <Nav />
      <div key={users.id}>
      <h1>{users.username}</h1>
      <p>{users.bio}</p>
      </div>
    </>
  )
}
j
Your where is looking for user created “now”
Copy code
createdAt: new Date(),
I think you should remove that condition
c
What should I put in its place?
@Joël
j
if you are trying to display a user profile you could probably do a where on username or id or email
c
Getting this error
@Joël
j
maybe @Ryan knows
r
Next.js cannot serialize
Date
objects, so you would need to add this plugin to make it work seamlessly.
2
c
Hey @Ryan could I get an example to use with my where function?
r
You don’t need to change your
where
function. You need to install this plugin and add it to your
.babelrc
c
Thanks @Ryan 😄
Getting another error...
Copy code
wait  - compiling...
error - ./pages/[...username].tsx
TypeError: E:\libby\libby-web\pages\[...username].tsx: get(...) is not a function
@Ryan or @Joël
t
This looks like an error in super json. can you provide a reproduction please?
c
I'm not sure what you would like me to reproduce?
• Create [...username].tsx file • Use code from below • Go to localhost:3000/Cheese
Copy code
import Head from "next/head";
import { PrismaClient } from '@prisma/client';
import Nav from '../components/Nav'

const prisma = new PrismaClient();

export async function getServerSideProps({ params }) {
  const users = await prisma.user.findMany({
    where: {
      name: params.toString()
    }
  })

  return {
    props: { users }
  }
}


export default function UserPage({ users }) {
  return (
    <>
      <Head>
        <title>{users.name}</title>
      </Head>
      <Nav />
      <div key={users.id}>
        <h1>{users.name}</h1>
        <p>{users.bio}</p>
      </div>
    </>
  )
}
Now the error is showing
Copy code
./pages/[...username].tsx
TypeError: E:\libby\libby-web\pages\[...username].tsx: d(...) is not a function
when I upgraded to next 10.0.5.