Vue · Middle · Question 65 of 75
How do you know whether router.push() actually navigated?
const failure = await router.push('/admin')
if (isNavigationFailure(failure, NavigationFailureType.aborted)) { /* blocked by a guard */ }- ✓Correct answer: Await it and check the result with
isNavigationFailure - 2It always navigates or throws
- 3Listen to
window.onpopstate
Explanation
Navigation can be aborted by a guard, cancelled by a newer navigation or be duplicated; these aren't exceptions.