Get data asynchronously and Synchronize

I would like to ask if there is any way to turn asynchronism into Synchronize, similar to ajax in jquery ; similar to this

function getData(){
    var dataList;
    $.ajax({
        async:false,
        ....
        success:function(data){
            dataList = data
        }
    })
    return dataList
}
var data = getData()

then I myself, because it is ws communication, is also asynchronous, so I would also like to ask if there is any way, like ajax , to directly return equals
. Here is my code

.
XDC.prototype.GetTGrpList = function (){
    return new Promise(function(resolve, reject){
        //
        that.sendCallback(tGrpReq, "tGrpReq", function(data){
            resolve(data)
        });
}
//
xdc.GetTGrpList().then(data => {
    //
})

I tried to use promise, async, generator can only get data in this chain, not directly equal to getting data. I don"t know if there is any god who can help me solve it. Thank you very much!


I tried to use promise, async and generator to get data only in this chain

async/await can be obtained without chaining

XDC.prototype.GetTGrpList = async function (){
        return that.sendCallback(tGrpReq, 'tGrpReq', function(data){
            return data;
        });
}
//
let response = await xdc.GetTGrpList();
// response
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-1b30693-2bd06.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-1b30693-2bd06.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?