Again, this is not a completely new task to you as this is almost the same as creating the CRUD pages you learned to create in Chapter 9, Adding a Server-Side Database. Let's recap:
- Create the following pages in the /pages/users/ directory for sending and fetching data:
users
├── index.vue
├── _slug.vue
├── add
│ └── index.vue
├── update
│ └── _slug.vue
└── delete
└── _slug.vue
- For example, use the following script to fetch all the available users:
// pages/users/index.vue
export default {
async asyncData ({ error, $axios }) {
try {
let { data } = await $axios.get('/api/users')
return {
users: data.data
}
} catch (err) {
// handle errors.
}
}
}
The scripts, templates, and directory structure in this Nuxt app are the same as the app you...