Skip to content

Commit

Permalink
Note on limit param in autoPagingToArray (#2074)
Browse files Browse the repository at this point in the history
* Note on `limit` param in `autoPagingToArray`

Makes it more explicit that the `limit` value passed to `autoPagingToArray` is the limit for the total number of items that will be fetched from Stripe, and not a limit for the number of items retrieved per fetch during multiple rounds of fetching.

* Update README.md

---------

Co-authored-by: Richard Marmorstein <52928443+richardm-stripe@users.noreply.github.com>
  • Loading branch information
tvanantwerp and richardm-stripe committed Apr 29, 2024
1 parent ced2e4b commit 9e607bf
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions README.md
Expand Up @@ -467,14 +467,15 @@ stripe.customers

This is a convenience for cases where you expect the number of items
to be relatively small; accordingly, you must pass a `limit` option
to prevent runaway list growth from consuming too much memory.
to prevent runaway list growth from consuming too much memory. Once the
`limit` number of items have been fetched, auto-pagination will stop.

Returns a promise of an array of all items across pages for a list request.

```js
const allNewCustomers = await stripe.customers
.list({created: {gt: lastMonth}})
.autoPagingToArray({limit: 10000});
.list({created: {gt: lastMonth}, limit: 100}) // 100 items per page
.autoPagingToArray({limit: 10000}); // Stop after 10000 items total
```

### Telemetry
Expand Down

0 comments on commit 9e607bf

Please sign in to comment.