[Vuejs]-Why async function continues after await (in vuex)

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

Leave a comment