Running the code bellow I just get "undefined". It seems like the async.parallel call executes the final function before the 4 parallel functions are finished.
function classify(filename) {
var stack = [];
var functionOne = async function(callback){
//call to an API
res = await classifierOne(filename);
callback(null, res);
}
var functionTwo = async function(callback){
//call to an API
res = await classifierTwo(filename);
callback(null, res);
}
var functionThree = async function(callback){
//call to an API
res = await classifierThree(filename);
callback(null, res);
}
var functionFour = async function(callback){
//call to an API
res = await classifierFour(filename);
callback(null, res);
}
stack.push(functionOne);
stack.push(functionTwo);
stack.push(functionThree);
stack.push(functionFour);
async.parallel(stack, function(err, res){
console.log(res[0]);
})
}