Reputation: 1703
I am using the async waterfall model to execute functions in sequence. However, within each function it does not execute statement in series. For instance below
var serviceconfig = loadCsv();
callback(null, serviceconfig);
I want the callback to only execute when the loadCsv() function returns the value but looks like it would continue the execution
apiRoutes.get('/api/:service/:subject', function(req, res) {
async.waterfall([
function(callback){
var serviceconfig = loadCsv();
callback(null, serviceconfig);
},
function(serviceconfig, callback){
console.log("serviceconfig final: " + serviceconfig);
callback(null, 'd');
},
function(argd, callback){
}], function (err, result) {
}
)
});
Upvotes: 0
Views: 40
Reputation: 134
You could, if it is possible for you, send the callback to the loadCsv, and let it handle it.
var serviceconfig = loadCsv(callback);
And then in loadCsv:
function loadCsv(callback) {
// code
callback(null, result);
}
Upvotes: 1