목록Next.js (1)
킹의 개발일지
토이 프로젝트에서 데이터를 요청할 때는 getServerSideProps안에서 api routes를 사용했다. 아래 두 코드는 index.js를 렌더링 할 때 요청 되는 메서드들이다. 우선, '/' 가 요청되면 server side에서 api routes를 호출하고 api routes는 다시 날씨 api를 요청하여 결과를 리턴하는 구조이다. export async function getServerSideProps(context) { const session = await getServerSession(context.req, context.res, authOptions) const url = process.env.WEATHER_REQ_URL +"/api/weather"; const options = { m..
Next.js
2023. 4. 27. 22:13