There is no great solution; the best I have found is to create a local function that will do the rest of the overall work as follows:
http.createServer(function (req, res) {
getSomeData(client, function(someData) {
function getMoreAndEnd() {
getMoreData(client, function(moreData) {
res.end();
});
}
if (someData) {
getSomeOtherData(client, function(someOtherData) {
getMoreAndEnd();
});
} else {
getMoreAndEnd();
}
});
});
source
share