Callbacks can't return a value as the code they would be returning to has already executed.
So you can do a couple things. One pass a callback function and once your async function gets the data call the callback and pass the data. Or pass the response object and use it in your async function
Passing a callback
exports.getJobInfoByID = function(req, res) {
var jobIDParam = req.params.id;
asyncJobInfo(jobIDParam,null,function(data){
res.send(data);
});
}
var asyncJobInfo = function(jobID, next,callback) {
//...
oozie.get(command, function(error, response) {
//do error check if ok do callback
callback(response);
});
};
Passing response object
exports.getJobInfoByID = function(req, res) {
var jobIDParam = req.params.id;
asyncJobInfo(jobIDParam,null,res);
}
var asyncJobInfo = function(jobID, next,res) {
//...
oozie.get(command, function(error, response) {
//do error check if ok do send response
res.send(response);
});
};