helium-js
helium-js copied to clipboard
Possible incorrect README.md documenation?
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
}