You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It can have many use cases like protecting a route or to request an API to populate the store before a route is loaded.
12
-
The plugin utilizes [vue-router navigation guards](https://router.vuejs.org/guide/advanced/navigation-guards.html) to implement easy to use, readable and more organized middlewares for your routes.
13
-
14
-
> **Please Note:** Due to the very limited scope of this module, I do not anticipate need to making many changes to it. Expect long stretches of zero updates—that does not mean that the module is outdated.
11
+
The plugin utilizes [vue-router navigation guards](https://router.vuejs.org/guide/advanced/navigation-guards.html)
12
+
to implement easy to use, readable and more organized middlewares for your routes.
15
13
16
14
## Installation
17
15
@@ -27,187 +25,12 @@ Install using Yarn
27
25
yarn add vue-router-middleware-plugin
28
26
```
29
27
30
-
## Usage
31
-
32
-
Create a middleware, `auth.js`
33
-
34
-
```javascript
35
-
importstorefrom'~/store'
36
-
37
-
exportdefault ({ to, from, redirect }) => {
38
-
if (!store.getters.isLoggedIn) {
39
-
redirect('/login')
40
-
// or
41
-
redirect(from)
42
-
// or
43
-
redirect(false)
44
-
}
45
-
}
46
-
```
47
-
48
-
> **Note:** Properties `to` and `from` are the same as in a vue router navigation gaurds. In __v2.0.0__ functin `next` has been replaced by `redirect` which can be called to redirect to a route. Now, there's no need to call `next` in each middleware to resolve it.
0 commit comments