Fix example for v1

This commit is contained in:
Sébastien Chopin 2017-07-09 12:23:03 +02:00
parent b921191f91
commit a869637615
2 changed files with 9 additions and 12 deletions

View File

@ -2,6 +2,5 @@ module.exports = {
build: {
vendor: ['axios']
},
css: ['~/assets/main.css'],
loading: false
css: ['~/assets/main.css']
}

View File

@ -1,5 +1,5 @@
<template>
<div class="container" :key="page">
<div class="container">
<nuxt-link v-if="page > 1" :to="'?page=' + (page - 1)">&lt; Prev</nuxt-link>
<a v-else class="disabled">&lt; Prev</a>
<span>{{ page }}/{{ totalPages }}</span>
@ -23,16 +23,14 @@ export default {
if (!from) return 'slide-left'
return +to.query.page < +from.query.page ? 'slide-right' : 'slide-left'
},
asyncData ({ query }) {
async asyncData ({ query }) {
const page = +query.page || 1
return axios.get(`https://reqres.in/api/users?page=${page}`)
.then((res) => {
return {
page: +res.data.page,
totalPages: res.data.total_pages,
users: res.data.data
}
})
const { data } = await axios.get(`https://reqres.in/api/users?page=${page}`)
return {
page: +data.page,
totalPages: data.total_pages,
users: data.data
}
}
}
</script>