API Documentation • Docs
API Documentation / isNavigationFailure
Function: isNavigationFailure()
isNavigationFailure(error, type)
isNavigationFailure(
error
,type
?):error is NavigationRedirectError
Check if an object is a NavigationFailure.
Parameters
• error: any
possible NavigationFailure
• type?: NAVIGATION_GUARD_REDIRECT
optional types to check for
Returns
error is NavigationRedirectError
Example
js
import { isNavigationFailure, NavigationFailureType } from 'vue-router'
router.afterEach((to, from, failure) => {
// Any kind of navigation failure
if (isNavigationFailure(failure)) {
// ...
}
// Only duplicated navigations
if (isNavigationFailure(failure, NavigationFailureType.duplicated)) {
// ...
}
// Aborted or canceled navigations
if (isNavigationFailure(failure, NavigationFailureType.aborted | NavigationFailureType.canceled)) {
// ...
}
})
isNavigationFailure(error, type)
isNavigationFailure(
error
,type
?):error is NavigationFailure
Parameters
• error: any
• type?: ErrorTypes
| NavigationFailureType
Returns
error is NavigationFailure