Skip to content

How to do pagination? #499

Closed Answered by posva
Shujee asked this question in Questions and Help
Discussion options

You must be logged in to vote

You handle pagination with query parameters. You can find a full working example in my talk demo

The relevant code looks like this

export const useArtworksSearchResults = defineColadaLoader(
  '/data-loaders/art-gallery/search',
  {
	// the key is needed for pinia colada but not for a basic loader
    key: (to) => [
      'artworks',
      { q: parseQuerySearch(to.query.q), page: parsePageQuery(to.query.page) },
    ],
    query: async (to) => {
      const query = parseQuerySearch(to.query.q)
      const page = parsePageQuery(to.query.page)

      if (query == null) {
        // stop the navigation
        throw new NavigationResult(false)
      }

      return searchArtworks(query, { page,

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Shujee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #498 on September 02, 2024 07:39.