pullfinger / localbitcoins-analytics

tools to perform analytics on a localbitcoins trading account
0 stars 2 forks source link

refactor download while loop to be a generator #6

Open pullfinger opened 9 years ago

pullfinger commented 9 years ago
while (target_url != null) {
var the_nonce = nonce() * 10
var options = yield buildOptions( api_key, the_nonce, target_url, api_secret, algorithm, encoding)
var result = yield request(options)
var response = result
var next_page = yield JSON.parse( response.body ).pagination
if ( next_page.next != '') {
target_url = next_page.next
thepayload.push(JSON.parse(response.body))
}
else
{
thepayload.push(JSON.parse(response.body))
console.log(response.body)
}
}