#pagination with api call error

1 messages · Page 1 of 1 (latest)

lyric lark
#

https://github.com/martinjh99/astro-site/blob/pagination/src/pages/yorkshire/[...page].astro

I am getting this error when using pagination with an api call...

    at paginateUtility (file:///home/martin/astro/astro-site/node_modules/astro/dist/core/render/paginate.js:22:24)
    at Module.getStaticPaths (/home/martin/astro/astro-site/src/pages/yorkshire/[...page].astro:10:8)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async callGetStaticPaths (file:///home/martin/astro/astro-site/node_modules/astro/dist/core/render/route-cache.js:29:17)
    at async getProps (file:///home/martin/astro/astro-site/node_modules/astro/dist/core/render/params-and-props.js:14:23)
    at async matchRoute (file:///home/martin/astro/astro-site/node_modules/astro/dist/vite-plugin-astro-server/route.js:37:7)
    at async run (file:///home/martin/astro/astro-site/node_modules/astro/dist/vite-plugin-astro-server/request.js:38:28)
    at async runWithErrorHandling (file:///home/martin/astro/astro-site/node_modules/astro/dist/vite-plugin-astro-server/controller.js:64:5)
    at async handleRequest (file:///home/martin/astro/astro-site/node_modules/astro/dist/vite-plugin-astro-server/request.js:34:3)```

Please ignore the debug line...
mossy stratus
#

How the const results looks like? Is possible to make some working minimal reproduction for example on codesandbox to test it?

lyric lark
#
  photoset: {
    id: '72177720324779486',
    primary: '54420979012',
    owner: '83528065@N00',
    ownername: 'martinjh99',
    photo: [
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object]
    ],
    page: 1,
    per_page: 500,
    perpage: 500,
    pages: 1,
    title: 'Yorkshire Air Museum',
    sorting_option_id: 'manual-add-to-end',
    total: 31
  },
  stat: 'ok'```

The actual picture details are the Objects - It certainly looks correct.
lyric lark
#

Am I adding the right const in the return statement?

mossy stratus
#

So the results constant is an object?

lyric lark
#

No the result should look like this - This is straight from Flickr's API explorer and I just copied the first picture's data...

    "photoset": {
        "id": "72177720324779486",
        "primary": "54420979012",
        "owner": "83528065@N00",
        "ownername": "martinjh99",
        "photo": [
            {
                "id": "54420979012",
                "secret": "814f3704b1",
                "server": "65535",
                "farm": 66,
                "title": "IMG_20250331_112004919_MF_PORTRAIT",
                "isprimary": "0",
                "ispublic": 1,
                "isfriend": 0,
                "isfamily": 0,
                "url_m": "https:\/\/live.staticflickr.com\/65535\/54420979012_814f3704b1.jpg",
                "height_m": 281,
                "width_m": 500,
                "url_o": "https:\/\/live.staticflickr.com\/65535\/54420979012_dcc91c835b_o.jpg",
                "height_o": 2592,
                "width_o": 4608
            }, ....
    ],
    page: 1,
    per_page: 500,
    perpage: 500,
    pages: 1,
    title: 'Yorkshire Air Museum',
    sorting_option_id: 'manual-add-to-end',
    total: 31
  },
  stat: 'ok'
}
``` - I truncated the pictures here it should be just straight json
mossy stratus
lyric lark
#

It worked fine when I didn't have the pagination and getStaticpaths - I thought it would just work straight out of the box...