How to retrieve value from callback ? I need first to find student by name and then calculate something and back result. Function which finds student by name returns err and result in callback like
function findStudentAndCalculate(name, cb);
cb is callback which takes as parameters err and student instance. I passed for cb
function calculateSomething(err, st){
if(err) throw new Error("Error")
var result = some stuff with st;
return result;
}
I should have this return to response to page for given url with name parameter
findStudentAndCalculate("John", calculateSomething);