I would like to know if it is possible to reload asyncData
in an emit in a function like this
Page
JavaScript
x
4
1
<template>
2
<component-child :products="products" @asyncData="asyncData" />
3
</template>
4
JavaScript
1
14
14
1
async asyncData({ $axios, store }) {
2
const customerId = store.getters['user/auth/customerId'];
3
if (!customerId) {
4
return;
5
}
6
const products = await customerApi.getProducts(
7
{ $axios },
8
customerId,
9
);
10
return {
11
products: products
12
};
13
},
14
component-child
JavaScript
1
6
1
methods: {
2
infiniteHandler() {
3
this.$emit('asyncData);
4
}
5
}
6
Is it possible? Otherwise how to do it?
Advertisement
Answer
You can try this.$nuxt.refresh()
to refresh fetch()
or asyncData()
hooks.
As explained in the documentation: https://nuxtjs.org/docs/2.x/concepts/context-helpers#refreshing-page-data