0

Can I check the value in terminal if I take console of the value received through getServerSideProps in the page component?

ex)

export const getServerSideProps = async({ req, res }) => {
  const data = useHook();
   // data = 1;
  return {
    data
  }
}

const MainPage = ({ data }) => {
   console.log(data); // i expect value = 1
   return <div>test</div>
}

can i check in terminal console??

jihwan
  • 57
  • 1
  • 5

2 Answers2

1

Props that are passed from getServerSideProps should be like this:

export const getServerSideProps = async({ req, res }) => {
  const data = useHook();
  return {
    props: {
        data
    },
  };
}
r4bb1t
  • 76
  • 2
0
const MainPage = ({ data }) => {
   console.log(data); // i expect value = 1
   return <div>test</div>
}
EdwinN1337
  • 551
  • 5
  • 4
  • I forgot the prop. What's the problem with the data not coming out even if I take a console after passing the prop? – jihwan Jun 14 '23 at 10:16