When using async
/ await
, it can be easy to forget to await
a promise which can result in async tasks running in an unexpected order. Thus, we require that every promise in an async
function is consumed in some way, so that there's a well-defined order in which async tasks are resolved. To fix this check, you can do one of the following:
async
from the function, and instead use normal promise chaining.await
the promise.await
it later.As a last resort, if you really want to use async
and can't await
the promise, you can just assign it to a variable, like so
let ignoredPromise = returnsPromise();
This makes your intent to ignore the result of the promise explicit, although it may cause “declared but never used” warning with some linters.