-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathroutes.js
44 lines (40 loc) · 1.14 KB
/
routes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import axios from 'axios';
import layout from './components/layout.vue';
import users from './components/users.vue';
import user from './components/user.vue';
import home from './components/home.vue';
export default [
{
path: '/',
component: layout,
children: [
{
path: '/',
component: home,
},
{
path: '/users',
component: users,
meta: {
resolve: {
users: _ => axios.get('https://reqres.in/api/users')
}
}
},
{
path: '/users/:id',
component: user,
meta: {
resolve: {
user: id => new Promise((resolve) => {
axios.get(`https://reqres.in/api/users/${id}`)
.then(({ data }) => {
resolve(data);
});
}),
},
}
}
]
}
];