I am creating a blog using Next.js and GraphCMS. I was fetching the data
The request file is :
`query MyQuery {
postsConnection {
edges {
cursor
node {
author {
bio
name
id
photo {
url
}
}
createdAt
slug
title
excerpt
featuredImage {
url
}
categories {
name
slug
}
}
}
}
}`;
const result = await request(graphqlAPI, query);
return result.postsConnection.edges;
And the Next.js pages/index.js file is:
export default function Home({ posts }) {
return (
<div className="container mx-auto px-10 mb-8">
<div className="grid grid-cols-1 lg:grid-cols-12 gap-12">
<div className="lg:col-span-8 col-span-1">
{posts.map((post, index) => (
<PostCard key={index} post={post.node} />
))}
</div>
<div className="lg:col-span-4 col-span-1">
<div className="lg:sticky relative top-8">
<PostWidget />
<Categories />
</div>
</div>
</div>
</div>
);
}
export async function getStaticProps() {
const posts = (await getPosts()) || [];
return {
props: { posts },
};
}
Can anyone please help me find the problem / where I am making mistake? I even gave access to GraphCMS to allow the function to work.