Home > Blockchain >  How to call an asyncData or fetch hook again in Nuxt?
How to call an asyncData or fetch hook again in Nuxt?

Time:10-15

Hello I want to recall asyncData function in methods or another solution when do the call api because i want to do a $emit when call this action which resets data I do that but is don't work

index.vue

<template>
    <my-orders
     :orders="orders
      @sendData="initOrders"
    />
</template>
<script>
 async asyncData({ $axios }) {
    const orders = await endpoint.getOrders({ $axios });
    return {
      orders
    };
  },
 methods: {
   async initOrders() {
      await this.asyncData
    },
}
</script>

Please help thank you

CodePudding user response:

this.$nuxt.refresh() can help you re-fetch any fetch() or asyncData() hooks.

  • Related