Hi!
I've started refactoring a Prismic + Next.JS project have been working on for a while.
Everything works when I'm fetching posts from getStaticProps, but now I would like to add a "Load More" button using the same function. This is where everything messes up and an error occurs when hitting the button, see below. Any ideas?
getStaticProps / Index.js
export async function getStaticProps() {
const client = PrismicClient();
const doc = (await client.getSingle("blog",
{ 'fetchLinks': ['blog_category.title'] })) || {};
const {posts} = await getBlogPosts({page: 1})
const header = (await client.getSingle("header")) || {};
const footer = (await client.getSingle("footer")) || {};
return {
props: {
doc,
header,
footer,
initalPosts: posts,
},
};
OnClick of index.js
const Blog = ({ doc, header, footer, initalPosts }) => {
const loadMore = async () => {
const test = await getBlogPosts({page: 1})
};
prismic-client.js
export const PrismicClient = (req = null, options = {}) => (
Prismic.client(apiEndpoint, Object.assign({ routes: Router.routes }, options))
)