I want to click on Load More bottom and get the rest of data in next.js how can do this?
in this page I'm using getServerSideProps to get data from api
My Page code is :
export default function Posts({ posts, popular }) {
const classes = useStyles();
return (
<motion.main
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
>
<InnerWrapper pbNone>
<Title title="Latest Post" subTitle />
</InnerWrapper>
<HeroSection data={posts} />
<InnerWrapper>
<Grid container spacing={3}>
<Grid item xs={12} sm={8}>
{posts.map(item => (
<HorizontalCard key={item.id} info={item} />
))}
<LoadMoreBtn />
</Grid>
<Grid item xs={12} sm={4}>
<div className={classes.marginBottom}>
<Title title={"Most Popular"} subTitle side={true} />
<SideList data={popular} />
</div>
<div className={classes.marginBottom}>
<SubscribeSide />
</div>
</Grid>
</Grid>
</InnerWrapper>
</motion.main>
);
}
export const getServerSideProps = async ({ query }) => {
// Fetch data from external API
const { data: posts } = await postLists(0);
const { data: popular } = await popularPost();
// Pass data to the page via props
return { props: { posts, popular } };
};