How to move throught result pages?

Hello!

I'm sending my blog posts by prop to slice. In response results there is prev and next page links. So is it posible to move throught result pages using this links in my slice?

//pages/[uid].js

...

export async function getStaticProps({}) {
const posts = 
    await client.query(Prismic.Predicates.at("document.type", "blog_post", ref ? { ref, lang: locale } : { lang: locale }),
  {pageSize: 1, page: 2})
return {
    props: {
      posts,
  };
};};

I'm getting response like:

{ 
  page: 2,
  results_per_page: 1,
  results_size: 1,
  total_results_size: 2,
  total_pages: 2,
  next_page: 'link',
  prev_page: 'link',
  results: []
}

And sending posts to components/slices/AllPosts.js

Is it posible to get other pages results in my slice using this next_page and prev_page links?

Thank you!

Hi @docodern,

Welcome to the Prismic community,

I'm not sure what you are trying to achieve. Can you explain what is the functional use-case and why you need to get the slices one by one and not all in one request? If you want to get all results, you don't need to you to use this limit {pageSize: 1, page: 2}

Generally, those will give you a link to fetch the following result, but again all depend on what you are trying to implement.

next_page: 'link',
prev_page: 'link',

You can also check our next.js Blog sample project to see how we implement blogposts

Normally this is how to supply your slices to sliceZone

Looking forward to your reply,
Fares

This thread has been closed due to inactivity. Flag to reopen.