vue-router#NavigationGuardNext TypeScript Examples
The following examples show how to use
vue-router#NavigationGuardNext.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.ts From cli with Apache License 2.0 | 6 votes |
routes: Array<RouteConfig> = [
{
path: '/error',
name: 'Error',
component: Error,
},
{
path: '/',
name: 'Home',
component: Home,
beforeEnter: async (
_to: Route,
_from: Route,
next: NavigationGuardNext<Vue>
) => {
if (!isEnvValid(process.env)) {
next('/error');
} else {
const res = await fetch(getTokenEndpoint());
const {token} = await res.json();
// Adding Coveo Headless engine as a global mixin so it can be available to all components
const engine = getEngine(token);
Vue.mixin({
beforeCreate: function () {
this.$root.$data.$engine = engine;
},
});
next();
}
},
},
]