“未定义”getServerSideProps 在 nextjs 中不起作用

问题描述 投票:0回答:0
import SearchHeader from '@/Components/Search/SearchHeader'
import React from 'react'
export async function getServerSideProps(context) {
  const data = await fetch('https://www.googleapis.com/customsearch/v1?key=AIzaSyAJ_TRxLePr0fo7IPd1mTWyUggQZ-AQ5qk&cx=561f6a3ff44b4403e&q=graphketing').then((res) => res.json());
  return {
    props: {
      result: data  
    }
  }
}

export default function page({result}) {
  console.log(result, "result")
  return (

      <SearchHeader />

  )
}

enter image description here

next.js next getserversideprops
© www.soinside.com 2019 - 2024. All rights reserved.