hello i want display data after infinite loading my data send by asyncData to page and the id page like this
Page
<script>
export default {
async asyncData({ $axios, store }) {
const customerId = store.getters['user/auth/customerId']
if (!customerId) {
return
}
const products = await customerApi.getProducts(
{ $axios },
customerId,
this.page
)
return {
products,
}
},
data() {
return {
page: 1,
}
},
}
</script>
I have the data of the first page. products is the props data send in my template. in my template i add a infinite loading
template
<template>
<generic-button v-if="!viewMore" inline @click="viewMore = true">
see more
</generic-button>
<client-only v-else>
<infinite-loading
:distance="800"
force-use-infinite-wrapper
@infinite="infiniteHandler"
></infinite-loading>
</client-only>
</template>
<script>
export default {
components: {
InfiniteLoading: () =>
process.client
? import('vue-infinite-loading')
: Promise.resolve({ render: (h) => h('div') }),
},
props: {
products: {
type: Array,
required: true,
},
},
data() {
return {
page: 1,
}
},
methods: {
infiniteHandler($state) {
// the method that will look for the data when the pagination changes
},
},
}
</script>
I would like that when the pagination is started that it relaunches the asyncData request by changing the page parameter to +1 and displays the data
thank you