How can we call Nextjs API from Nextjs Pages?

29 Views Asked by At

I want to load data on the home page for which I've written an API in nextjs project. I am able to call that api at client side using useEffect but I want to load the data at server side only so I was trying to call the api from getServerSideProps. My question here is that is this possible? calling the api from getServerSideProps as I was getting error when I use fetch and deploy it. and If I directly try to use the api function inside getServerSideProps then it says that the status

This is the code I am using Code Image This is the error I am getting enter image description here

If I try to use statusCode instead of status then also it throws error enter image description here

0

There are 0 best solutions below