I've been doing it a little differently. Here's a helper function that I wrote in order to parse the account history of any given account, but only output the "transfer" transactions. The general idea is the same, but here it is so folks can see a concrete example of a test. In this case parsing out only transactions:
let steem = require('steem');
steem.api.setOptions({ url: 'https://api.steemit.com' });
function getAllAccountTransactions( username ){
steem.api.getAccountHistory(username, -1, 0, (err, result) => {
limit = result[0][0];
while(limit >= 0){
steem.api.getAccountHistory(username, limit, 100, (err, result) => {
result.map((r) => {
r[1].op[0] == 'transfer' ? console.log(r[1]) : '' ;
});
});
limit -= 101;
}
});
}
process.on('unhandledRejection', (reason, p) => {
});
getAllAccountTransactions('sha256md5');
RE: How to iterate over account history items