strapi icon indicating copy to clipboard operation
strapi copied to clipboard

Handling Pagination Nuxt3

Open IzakJackson opened this issue 3 years ago • 0 comments

Hey, I'm new to Strapi and I'm using the Strapi module on Nuxt 3.

I'm wanting to paginate the results but I'm not too sure what the best practices would be for it.

I'm using this to fetch the content from the API:

import type { Portfolio } from "~/types";
import type { Strapi4Response } from "@nuxtjs/strapi";

const currentPage = 1;

// Fetch Case Studies
const { find } = useStrapi4();
const response = await find<Strapi4Response<Portfolio>>(
  "portfolios?populate=*&pagination[pageSize]=10&pagination[page]=" +
    currentPage
);

And I have a pagination component:

<NavigationPagination
   :totalPages="response.meta.pagination.pageCount"
   :perPage="response.meta.pagination.pageSize"
   :currentPage="response.meta.pagination.page"
   @pagechanged="onPageChange"
/>

How can I query the API to change the page?

IzakJackson avatar Feb 24 '22 13:02 IzakJackson