4π
β
An async function
like requiresAuth
always returns a promise that is resolved with the return value (including undefined
if no return
statement is evaluated). It does not make a difference whether the function ends without a return
, with a return;
, with a return undefined;
, with a return Promise.resolve()
or with a return Promise.resolve(undefined)
β they are indistinguishable from the outside.
Either return a boolean and then branch on it, or just throw an exception.
π€Bergi
Source:stackexchange.com