I have this piece of code
module.exports.AAA=function(){
let request= test(function(){
//一段异步代码
});
let data;
request.on('data',function(data){})
request.on('end',function(){})
}
With the above code, how can I directly obtain the value of data
when calling AAA()
? How to write if you use async
and await
?
foobar.js
Here is a piece of code for reference.
node --harmony-async-await foobar.js