How to change the value of data
inside the asyncCall()
and set it to the resolve value of the promise which is b
.
What I wanted is that the asyncCall()
will return b
.
But what happen is that asyncCall()
returns a Promise object.
function resolveAfter2Seconds(data) {
return new Promise(resolve => {
resolve(data);
});
}
async function asyncCall() {
let data = "a";
var result = await resolveAfter2Seconds("b");
data = result;
return data;
}
asyncCall();