如何将值传递给 getServerSideProps?

时间:2021-02-12 08:03:46

标签: reactjs next.js

使用 nextjs,我有包含用户 JWT 的状态,这需要传递到 getServerSideProps 中的请求中。

export async function getServerSideProps(ctx) {

  const res = await fetch('http://localhost:1337/publics')
  const data = await res.json()
  const theData = data[ctx.query.id - 1]

  return {
    props: {data: theData}, 
  }
}

我如何在这里传递 JWT?

0 个答案:

没有答案