Skip to content

Commit

Permalink
🌿 Update README.md pagination examples (#12)
Browse files Browse the repository at this point in the history
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
  • Loading branch information
fern-support and fern-api[bot] authored Dec 10, 2024
1 parent 45cb3f0 commit 1fafb7d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ response, err := client.Payments.List(
List endpoints are paginated. The SDK provides an iterator so that you can simply loop over the items:

```go
ctx := context.TODO()
page, err := client.Payments.List(
context.TODO(),
ctx,
&square.PaymentsListRequest{
Total: square.Int64(100),
},
Expand All @@ -85,7 +86,7 @@ if err != nil {
return nil, err
}
iter := page.Iterator()
for iter.Next() {
for iter.Next(ctx) {
payment := iter.Current()
fmt.Printf("Got payment: %v\n", *payment.ID)
}
Expand All @@ -101,7 +102,7 @@ for page != nil {
for _, payment := range page.Results {
fmt.Printf("Got payment: %v\n", *payment.ID)
}
page, err = page.GetNextPage()
page, err = page.GetNextPage(ctx)
if errors.Is(err, core.ErrNoPages) {
break
}
Expand Down

0 comments on commit 1fafb7d

Please sign in to comment.