Use http.get in node to get data. Why can't export export it? How to export the obtained data

the approximate code is as follows:

let http = require("https")
let obj ;
//get 
http.get("https://c.y.qq.com/",function(req,res){
let html="";
req.on("data",data =>{
    html+=data;
    //console.log(data);
});
req.on("end",() => {
    //obj = eval ("(" + html + ")");
     obj = JSON.parse(html);
    //console.log(obj);
    export {obj}
});
});

data can be exported by console.log, but data cannot be exported by export.


export can only be on the outermost layer.

let dd=null
req.on ('end', () = > {

)
//obj = eval ("(" + html + ")");
 obj = JSON.parse(html);
//console.log(obj);
dd=obj

});
});

export {dd}


Export
with a promise package. In addition, export is the syntax of es6 . I don't know if you handled it

.
let https = require('https');
// 
var p = new Promise(function(resolve) {
  https.get('https://c.y.qq.com/',function(req,res){
        let html='';
        req.on('data',data =>{
            html+=data;
        });
        req.on('end',() => {
            resolve(JSON.parse(html))
        });
    });
});
export {p}

Asynchronous with Synchronize?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37e07-2b91f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37e07-2b91f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?