# Cursor Pagination is always returning the same cursor

**URL:** <https://forum.heroiclabs.com/t/cursor-pagination-is-always-returning-the-same-cursor/2606>\
**Category:** Runtime Framework\
**Created:** [May 5, 2022, 10:50am UTC](https://forum.heroiclabs.com/t/cursor-pagination-is-always-returning-the-same-cursor/2606 "2022-05-05T10:50:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JMac](https://avatars.discourse-cdn.com/v4/letter/j/258eb7/32.png) [@JMac](https://forum.heroiclabs.com/u/JMac)\
**Post date:** [May 5, 2022, 10:50am UTC](https://forum.heroiclabs.com/t/cursor-pagination-is-always-returning-the-same-cursor/2606/1 "2022-05-05T10:50:38Z")

</div>

Hi,

I am calling the nkRuntime storageList using a cursor to return paginated data.

On the first call, the cursor is null and it returns the first page of data and the first cursor.  
On the second call, I pass in the first cursor and it returns a second page but the cursor is the same as the first result, so the third call returns the second page again.

I have tried looping the calls to storageList and logging the cursor each time and it is always the same.

Here is my code. Is there something I have missed in implementing how the cursor is used?

UPDATE: On further investigation, I determined that when limit (numDocs) is null, the cursor returns correctly with the default 100 limit. If I pass in 100 or greater as the limit, it also works correctly. Using any number below 100 returns the same cursor on all requests.

public getDataList\_Cursor = function(collection: string, nk: nkruntime.Nakama, numDocs: number, cursor?: string){

```
    this.logger.debug(`<<<<GETTING DATALIST>>>>`);

    if(cursor === ""){

        cursor = null;

    }

    const vgs = {};

    let vgResult: nkruntime.StorageObjectList = nk.storageList("00000000-0000-0000-0000-000000000000", collection, numDocs);

       

    vgResult.objects?.forEach((vgDoc) => {

        vgs[vgDoc.key] = vgDoc.value['count'];

    });

    // if there are more docs //

    let count: number = 0

    while (vgResult.cursor) {

        this.logger.info(vgResult.cursor);

        vgResult = nk.storageList("00000000-0000-0000-0000-000000000000", collection, numDocs, vgResult.cursor);

        if(vgResult.objects?.length > 0){

            vgResult.objects?.forEach((vgDoc) => {

                vgs[vgDoc.key] = vgDoc.value['count'];

            });

        }

        count++

        if(count === 10){

            this.logger.info("<<<<BREAKING>>>>")

            break;

        }

    }
```

---

<div class="post-metadata">

**Author:** ![mharis](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/mharis/32/969_2.png) [@mharis](https://forum.heroiclabs.com/u/mharis)\
**Post date:** [May 10, 2022, 11:57am UTC](https://forum.heroiclabs.com/t/cursor-pagination-is-always-returning-the-same-cursor/2606/2 "2022-05-10T11:57:26Z")

</div>

Thanks for reporting this - tracking of this issue moved to github: [Cursor Pagination is always returning the same cursor when limit is \<100 · Issue #848 · heroiclabs/nakama · GitHub](https://github.com/heroiclabs/nakama/issues/848)
