DO NOT USE: WRONG EXAMPLE
WITHOUT RESOLVE DIRECTIVE
by RomainMazB
HTML
<html>
<body>
<ul id="fakeConsole"></ul>
</body>
</html>
JavaScript
$(document).ready(function(){
function resolveAfter2Seconds() {
return new Promise(resolve => {
setTimeout(() => {
return 'resolved';
}, 2000);
});
}
async function asyncCall() {
consoleLog('calling');
var result = await resolveAfter2Seconds();
consoleLog(result);
// expected output: 'resolved'
}
function consoleLog(message) {
$("ul#fakeConsole").append('<li>'+message+'</li>');
}
asyncCall().then(function() { consoleLog('then calling') });
});