cognitedata/cognite-sdk-js

.list not returning any data without auto-paging methods

Closed this issue · 0 comments

To get data from the .list-calls you need to call on of:

  • for await (const asset of .list())
  • .list().autoPagingToArray()
  • .list().autoPagingEach()

You cannot simply call await .list() to get some data.

Solution
Make .list() return a Promise than will resolve to an array of items (without auto-pagination).
Example: await assets.list() will return a list (limit: 100 = default) of assets
Example: await assets.list({ limit: 5 }) will return a list (limit: 5) of assets
Example: await assets.list({ limit: 1001 }) will throw exception (400 - bad request)