How to return the final result/callback to the calling function? All examples in the documentation only show console.log() options.
The following code is just for example purposes.
function foo(input) {
async.parallel([
function(callback) {
callback(null, input.one);
},
function(callback) {
callback(null, input.two);
}
],
function(err, results) {
// What to do here? all examples include console.log()
// I want to return the result ([1, 2]) to the calling function!
});
}
var data = {"one": 1, "two": 2};
var bar = foo(data);
console.log(bar); // Will return [1, 2]
Edit: This question was marked as duplicate. The other post did not explain how this was done to someone with marginal experience with javascript and callbacks.