반응형
Sample.getInitialProps = async () => {
const { data } = await axios.get(
encodeURI(
`http://alb-diaas-07480.ap-northeast-2.elb.amazonaws.com:3000/왕십리`
)
);
return data;
};
export async function getServerSideProps() {
const data = await axios
.get(
encodeURI(
`http://alb-diaas-07480.ap-northeast-2.elb.amazonaws.com:3000/왕십리`
)
)
.then((res) => {
console.log("response");
return res.data.data[0];
})
.catch((error) => {
return error.message;
});
return {
props: {
data,
},
};
}
반응형
'프론트엔드 웹 > Next' 카테고리의 다른 글
Next.js SWR 예제 (0) | 2022.03.24 |
---|---|
Next.js Image Resize (0) | 2022.03.24 |
[에러해결] Next.js Reference Error: document is not defined (0) | 2022.02.23 |
Next.js에서 현재 URL 클립보드에 복사하기 (0) | 2022.02.16 |
[에러해결] ./node_modules/@emotion/is-prop-valid/dist/emotion-is-prop-valid.browser.esm.js Module build failed (0) | 2022.02.16 |