I get an error that I don't understand when I try to build my next js project.
index.js :
import FeaturedPosts from "@/components/home-page/Featured-Posts";
import axios from "axios";
import { Fragment } from "react";
import { Toaster } from "react-hot-toast";
import Hero from "../components/home-page/Hero";
export default function HomePage({postList}) {
return (
<Fragment>
<Toaster />
<Hero />
<FeaturedPosts postList={postList} />
</Fragment>
);
}
export const getStaticProps = async () => {
const res = await axios.get("http://localhost:3000/api/posts")
return{ props: {
postList: res?.data
}}
}
Error:
error - ESLint: Failed to load config "next/babel" to extend from. Referenced from: /vercel/path0/.eslintrc.json
info - Creating an optimized production build...
info - Compiled successfully
info - Collecting page data...
info - Generating static pages (0/6)
info - Generating static pages (1/6)
info - Generating static pages (2/6)
I thought that it could be due to not having access to environment variables but, but taking them out of.env didn't change anything.
The issue was that I was using getStaticProps instead of getServerSideProps.