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
Menu