Level 58
The problem is that you are not returning the result of the asyncCall() function. The asyncCall() function returns a promise, so you need to use the await keyword to get the result of the promise.
Try this:
let data2 = data.slice(0, 20).map(async function (val, index) {
function resolveAfter2Seconds() {
return new Promise(resolve => {
setTimeout(() => {
resolve('resolved');
}, 2000);
});
}
async function asyncCall() {
console.log('calling');
const result = await resolveAfter2Seconds();
console.log(result);
// Expected output: "resolved"
return result;
}
var test= await asyncCall();
return {
name: val.name,
author: val.owner.login,
description: test,
};
});