nextjs 服务端渲染请求参数

Post.getInitialProps = async function (context) {
  const { id } = context.query
  const res = await fetch(`http://api.tvmaze.com/shows/${id}`)
  const show = await res.json()

  console.log(`Fetched show: ${show.name}`)

  return { show }
}

  

posted @ 2019-01-09 21:47  winyh  阅读(1370)  评论(0编辑  收藏  举报