I'm playing with async/await and with the code below, shouldn't response be empty or null until the setTimeout in the response const has finished after 5 seconds? and shouldn't response return xyz instead of 1?
async function test() {
try {
const response = await setTimeout(
function() {
const obj = {};
obj.text = "xyz";
console.log('should console log after 5 seconds')
return obj;
},
5000)
if (response) {
console.log(`response is ${response}`)
console.log(`response.text is ${response.text}`)
}
}
catch(err) {
console.log(err)
}
}
test();