Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible incorrect README.md documenation? #233

Open
oliverswitzer opened this issue Sep 10, 2021 · 0 comments
Open

Possible incorrect README.md documenation? #233

oliverswitzer opened this issue Sep 10, 2021 · 0 comments

Comments

@oliverswitzer
Copy link

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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant