When using node to get data in the network, after returning the data asynchronously, Synchronize has finished, is there any way to return out to another module to use?

1. Want to use node and cheerio to grab data in the network, and then use it in another module, but because it is asynchronous to obtain data, the current Synchronize code has been executed, the obtained variables or return are empty, exports can not be exported, in addition to temporary use or storage in the processing function, is there any way to continue to use, or export to another module, return.

2.`function getTitle (url,i) {
console.log ("getting contents of page" + iTunes");

http.get(url+i+".html",res=>{
var chunks = [];
res.on("data",function(chunk){
  chunks.push(chunk);
});
res.on("end",function(){
  var html = iconv.decode(Buffer.concat(chunks),"gb2312");
  var $ = cheerio.load(html,{decodeEntities:false});
  var asyRes = $(".co_content8 .ulink");
  $(".co_content8 .ulink").each(function(index,ele){
    var dom = $(ele);
    titles.push({
      title:dom.text()
    })
  });
  if (i<2) {
    getTitle(url,PPindex);
    //
  }else {
    // if (titles) {
    //   save(titles);
    // }
    //,..titles
  }
})

});
} `

Mar.03,2021

use async/await to write the asynchronous request in the async function. After the request is successful, return go out


there are many ways to get information asynchronously, callbacks can be used, Promise, can be used, async/await, can be used. See you like


is my own idea is wrong, want to use data, can only make a persistent server, after getting the request, use..

Menu