# Error listing a collection in TypeScript with Nakama 3.3.0

**URL:** <https://forum.heroiclabs.com/t/error-listing-a-collection-in-typescript-with-nakama-3-3-0/1746>\
**Category:** Game Design\
**Tags:** server-framework, typescript\
**Created:** [June 28, 2021, 8:24pm UTC](https://forum.heroiclabs.com/t/error-listing-a-collection-in-typescript-with-nakama-3-3-0/1746 "2021-06-28T20:24:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leonidas](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/leonidas/32/519_2.png) [@Leonidas](https://forum.heroiclabs.com/u/Leonidas)\
**Post date:** [June 28, 2021, 8:24pm UTC](https://forum.heroiclabs.com/t/error-listing-a-collection-in-typescript-with-nakama-3-3-0/1746/1 "2021-06-28T20:24:57Z")

</div>

Hi, before submitting a bug, I would like to check if I am doing everything right:

1. Users store data in the same collection:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/heroiclabs/original/1X/0ab0a08a93279542783416776a7249110ea65de9.png)

1. In the runtime code we would like to fetch that data from all users in the same query (since we don’t know which users have written in that collection). So we pass an empty string as the docs state to the `storageList` method:

```auto
const getInstances: nkruntime.RpcFunction = function (
  ctx: nkruntime.Context,
  logger: nkruntime.Logger,
  nk: nkruntime.Nakama,
  payload: string
) {
  const data = JSON.parse(payload);
  const collection = `island-user-instances_${data.islandId}`;
  const result = nk.storageList("", collection, 10000);

  return JSON.stringify(result);
};

```

That query fails with the following error:

```auto
{"level":"error","ts":"2021-06-28T20:24:13.340Z","caller":"server/runtime_javascript.go:490","msg":"JavaScript runtime function raised an uncaught exception","mode":"rpc","id":"get_instances","error":"TypeError: expects empty or valid user id at github.com/heroiclabs/nakama/v3/server.(*runtimeJavascriptNakamaModule).storageList.func1 (native)"}

```

If we pass a valid userID on the other hand the query works as expected. We are using the latest Nakama build using docker, locally.

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [July 6, 2021, 4:09pm UTC](https://forum.heroiclabs.com/t/error-listing-a-collection-in-typescript-with-nakama-3-3-0/1746/2 "2021-07-06T16:09:35Z")

</div>

Hey @Leonidas, thank you for this post, I’ve looked into it and it is a bug in the JS runtime, we’ll fix it within the next release of the server.

---

<div class="post-metadata">

**Author:** ![Leonidas](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/leonidas/32/519_2.png) [@Leonidas](https://forum.heroiclabs.com/u/Leonidas)\
**Post date:** [July 21, 2021, 4:08pm UTC](https://forum.heroiclabs.com/t/error-listing-a-collection-in-typescript-with-nakama-3-3-0/1746/3 "2021-07-21T16:08:17Z")

</div>

Hi @sesposito, do you know on which server release this would be addressed? If there is an active issue to follow let me know, many thanks.

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [July 21, 2021, 4:24pm UTC](https://forum.heroiclabs.com/t/error-listing-a-collection-in-typescript-with-nakama-3-3-0/1746/4 "2021-07-21T16:24:13Z")

</div>

@Leonidas the fix is included in the latest release [Release v3.4.0 · heroiclabs/nakama · GitHub](https://github.com/heroiclabs/nakama/releases/tag/v3.4.0) (sadly the fix is missing from the change log).

---

<div class="post-metadata">

**Author:** ![Leonidas](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/leonidas/32/519_2.png) [@Leonidas](https://forum.heroiclabs.com/u/Leonidas)\
**Post date:** [July 21, 2021, 7:35pm UTC](https://forum.heroiclabs.com/t/error-listing-a-collection-in-typescript-with-nakama-3-3-0/1746/5 "2021-07-21T19:35:15Z")

</div>

Thank you, it worked! One minor issue, when using TypeScript you get a type error if you pass empty (null, empty string `''` didn’t work):

```auto
  const result = nk.storageList(
    // @ts-ignore
    null,
    collection,
    10000
  );

```

I had to instruct the compiler to ignore that error.

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [July 22, 2021, 1:00pm UTC](https://forum.heroiclabs.com/t/error-listing-a-collection-in-typescript-with-nakama-3-3-0/1746/6 "2021-07-22T13:00:26Z")

</div>

Thank you for catching this @Leonidas, the `nk.storageList` TS definition has been updated.

---

<div class="post-metadata">

**Author:** ![dzso](https://avatars.discourse-cdn.com/v4/letter/d/f0a364/32.png) [@dzso](https://forum.heroiclabs.com/u/dzso)\
**Post date:** [September 7, 2023, 3:08pm UTC](https://forum.heroiclabs.com/t/error-listing-a-collection-in-typescript-with-nakama-3-3-0/1746/7 "2023-09-07T15:08:00Z")

</div>

This doesn’t seem to be fixed, and I’m seeing a bigger issue with the storageList response: [Response from storageList does not respect permissions!](https://forum.heroiclabs.com/t/response-from-storagelist-does-not-respect-permissions/4307)
