[Solved] NodeJs function wait until callback return value


make your function async and then await xyz()

var http = require('http');

var foo = async function(req, res){
  var a = await xyz('5'); 
  res.end(a);
  console.log(a);
}

function xyz(arg){
  var aa = 55;
  return aa;
}

http.createServer(foo).listen(8000);
console.log('start server');

2

solved NodeJs function wait until callback return value