I have something like
new Promise (resolve, reject) ->
trader.getTrades limit, skip, (err, trades) ->
return reject err if err
resolve trades
.each (trade) ->
doStuff trade
limit
is set to some arbitrary number, say 10
and skip
starts at 0
. I want to keep increasing skip
until there are no more trades
.
The doStuff
is a function I'm using to process each trade.
This works the first time, but I want to get more trades in a paginated fashion. Specifically, I want to run trader.getTrades
with a higher skip
until trades.length
is 0