kaelad
kaelad
Error message on Roll: await is only valid in async functions and the top level bodies of modules
That error is referring to the fact that the function you're giving in addEventListener isn't async. If you add an await to a function, that function needs to be labeled as async. Something like this would fix that.
_button.addEventListener("click", async function(event){
let r = new Roll("1d20");
await r.toMessage();
console.log(r.total)
});
_button.addEventListener("click", async function(event){
let r = new Roll("1d20");
await r.toMessage();
console.log(r.total)
});
5 replies