Skip to content

Commit b88467e

Browse files
committed
Merge pull request github#747 from github/update-1428355494
2 parents 70d2b79 + 8b8b8ce commit b88467e

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

content/guides/traversing-with-pagination.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,10 @@ The loop will finish when there is no `rels[:next]` information to consume (in o
141141
words, we are at `rels[:last]`). It might look something like this:
142142

143143
#!ruby
144-
loop do
145-
puts last_response.data.items.first.path
144+
puts last_response.data.items.first.path
145+
until last_response.rels[:next].nil?
146146
last_response = last_response.rels[:next].get
147-
sleep 4 # back off from the API rate limiting; don't do this in Real Life
148-
break if last_response.rels[:next].nil?
147+
puts last_response.data.items.first.path
149148
end
150149

151150
Changing the number of items per page is extremely simple with Octokit.rb. Simply
@@ -170,11 +169,10 @@ your code should remain intact:
170169

171170
puts "And here's the first path for every set"
172171

173-
loop do
174-
puts last_response.data.items.first.path
172+
puts last_response.data.items.first.path
173+
until last_response.rels[:next].nil?
175174
last_response = last_response.rels[:next].get
176-
sleep 4 # back off from the API rate limiting; don't do this in Real Life
177-
break if last_response.rels[:next].nil?
175+
puts last_response.data.items.first.path
178176
end
179177

180178
## Constructing Pagination Links

0 commit comments

Comments
 (0)