score:2

infinitequeries don't really care how your backend delivers a "cursor" to the next page, it just matters that the backend delivers something.

basically, whatever is returned from getnextpageparam will be injected into the queryfn as pageparam. here is an example that might fit your use-case:

const { data } = useinfinitequery(
    'key',
    ({ pageparam }) => axios.get(myurl + '?offset=' + pageparam?.offset ?? 0),
    {
        getnextpageparam: (lastpage) => lastpage?.meta
    }
)

the concept of a "page" is merely what ever your backend returns for a single fetch. so here, on the first fetch (for page 0), we have no pageparam, so we initalize with offset: 0. then, we fetch with that, and the backend returns the first set of data (a page), and we extract the meta info for it (offset = 20 or whatever).

if you call fetchnextpage(), the queryfn will be called with that meta information, so the next fetch does ?offset=20. the backend delivers offset: 40 as meta and the infinity continues.

hope that explains it :)


Related Query

More Query from same tag