I am trying to chain promises so that doQuery(0) executes then doQuery(1), etc... sequentially until doQuery(9).
My problem is that i is always equals to 10 in the callback function.
doQuery(0) executes then doQuery(10).
How do I pass each value of i in the callback function?
var promise = doQuery(0);
for (var i = 1; i < 10; i++) {
promise = promise.then(function() {
doQuery(i);
});
};