How to return an Ajax result using async/await? [duplicate]

either

function f() { 
  return $.get("https://stackoverflow.com/");
};

async test() {
  var x = await f()
  console.log(x)
}

test()

or

f().then(function(res) {
    console.log(res)
}

the async/await is just another way to write the same logic.

Leave a Comment