Why won't the following snippet work here on Stack Overflow?
I'm trying to add some example of basic async/await and returned promises.
This exact same piece of code works just fine on my devdevelopment environment,. I'm using BabelBabel, but I've seen snippets with async await functions here on SOStack Overflow before.
What's happening?
It gives the error:
{
"message": "Script error.",
"filename": "",
"lineno": 0,
"colno": 0
}
function bar() {
return new Promise((resolve,reject) => {
setTimeout(()=> {
resolve('resolved after 1500ms');
},1500);
// return resolve('resolved');
});
}
async function foo() {
const result = await bar();
console.log(result);
}
foo();
I'm on Chrome version 75.0.3770.80 (official build) (64-bit).