function nodeSearch(path) {
lookup.getChildrenAsCallback(path, function(err, nodesFromCb) {
if (nodesFromCb.length > 0) {
for (var i = 0; i < nodesFromCb.length; i++) {
console.log("i", i);
nodesFrom.push(path + "/" + nodesFromCb[i]);
lookup.getChildrenAsPromise(path + "/" + nodesFromCb[i])
.then(function(nodesFromPromise) {
nodesFrom.push(path + "/" + nodesFromCb[i] + "/" + nodesFromPromise[0]);
nodeSearch(path + "/" + nodesFromCb[i] + "/" + nodesFromPromise[0]);
});
}
} else {
return;
}
});
}
My intention was to function nodeSearch call itself again in a for loop after getting the result from promise.But now for loop executes continuously without waiting for the result from the promise. I am not sure how to use promise in these scenario could someone please help. Thanks in advance.