const getLang = function (req) {
translate.detect(req.body.phrase, function (err, res) {
if (err) throw err;
console.log(res);
return res;
});
router.post('/addPhrases', (req, res) => {
var lang = getLang(req);
console.log(lang);
})
console.log(lang) from second function print undefined, it runs before the first function make a return
how can I fix it?