Javascript function returning undefined value in nodejs
I am writing code for getting data. First I call **getsomedata** function to get data and inside getsomedata function I am calling another function getRandomdata to get data and returning it back to the previous function but it is returning undefined . But in getRandomdata data could be seen in console.log . Do I need to use callbacks ? router.get('/get-data', function (req, res, next) { var result = getsomedata(some_parameter); console.log(result); // receiving undefined res.send(result); }); function getsomedata(some_parameter_recieved) { var getsomedata = getRandomdata(random_params);