Skip to content

Commit

Permalink
fix pagination example
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver006 committed Feb 20, 2015
1 parent 95df6f9 commit a10c619
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,29 +74,28 @@ func DropletList(client *godo.Client) ([]godo.Droplet, error) {
for {
droplets, resp, err := client.Droplets.List(opt)
if err != nil {
return err
return nil, err
}

// append the current page's droplets to our list
for _, d := range droplets {
list = append(list, d)
}

// if we are at the last page, break out the for loop
if resp.Links.IsLastPage() {
break
}
// if we are at the last page, break out the for loop
if resp.Links == nil || resp.Links.IsLastPage() {
break
}

page, err := resp.Links.CurrentPage()
if err != nil {
return err
page, err := resp.Links.CurrentPage()
if err != nil {
return nil, err
}

// set the page we want for the next request
opt.Page = page + 1
// set the page we want for the next request
opt.Page = page + 1
}

return nil
return list, nil
}

```

0 comments on commit a10c619

Please sign in to comment.