helium-js icon indicating copy to clipboard operation
helium-js copied to clipboard

Possible incorrect README.md documenation?

Open oliverswitzer opened this issue 3 years ago • 0 comments

Hi,

I could not get this async iterator block (from the README.md) to work locally:

The asynchronous iterator can be used directly via the for-await-of syntax:

for await (const account of client.accounts.list()) {
  account //= Account
  // do something with account

  // after some condition is met, stop iterating
  if (someConditionMet)
    break
}

client.accounts.list() returns a Promise<ResourceList<Account>> which is not iterable due to the wrapper promise. Adding an await in front of client.accounts.list unwrapped it and made it work.

for await (const account of await client.accounts.list()) {
  account //= Account
  // do something with account

  // after some condition is met, stop iterating
  if (someConditionMet)
    break
}

oliverswitzer avatar Sep 10 '21 04:09 oliverswitzer