Is it possible to return values in async code?
For example, I have some async code that looks like this:
async function(a,b){
fetch('url'+b)
.then(res) => res.json())
.then(data) => obj = data
.then() => {
//writes to html just fine
var x = obj.jsonvalue;
var y = obj.otherjsonvalue;
//create an array of these values
var z = [x,y];
return z;
}
Obviously, when it returns 'z' I can see that it's only returning a promise. Is there a way to return the actual values of z, ie the array?