Open 4rocky4 opened 6 years ago
I would like to calls getCandles multiple times in a promise loop.
function test(coinList) { var deferred = Q.defer(); var promises = []; coinList.forEach(function (coin) { promises.push(getCandles(coin)); }); return Q.allSettled(promises).then(function (results) { var listMarkets = []; results.forEach(function (r) { console.log(r.value.MarketName); }); return listMarkets; }); } function getCandles(coin) { var deferred = Q.defer(); bittrex.getcandles({ marketName: coin.MarketName, tickInterval: 'hour', // intervals are keywords (oneMin, fiveMin, hour, thirtyMin, Day) }, function (data, err) { if (err) { console.log('1 err:' + coin.MarketName); deferred.resolve(coin); } if (data) { console.log('1 :' + coin.MarketName); coin.Test = 10; deferred.resolve(coin); } }); return deferred.promise; }
... 1 :BTC-NEOS 1 :BTC-LGD 1 :BTC-SPR 1 :BTC-XMG 1 :BTC-VTC 1 :BTC-QTUM 1 :BTC-MAID 1 :BTC-DOPE 1 :BTC-EXCL 1 :BTC-PAY 1 :BTC-NLG 1 :BTC-REP 1 err:BTC-OMG 1 err:BTC-GAM 1 err:BTC-KORE 1 err:BTC-SNT 1 err:BTC-NAV 1 err:BTC-EFL 1 err:BTC-EBST 1 err:BTC-PKB
I tried to call the same market with each request, I have the same problem.
Should I change something in my function to fix it or is there a bug ?
Thanks for any help.
I would like to calls getCandles multiple times in a promise loop.
I tried to call the same market with each request, I have the same problem.
Should I change something in my function to fix it or is there a bug ?
Thanks for any help.