diff --git a/packages/vue-app/template/mixins/fetch.client.js b/packages/vue-app/template/mixins/fetch.client.js index cc5ee8fbbd..1cb99350be 100644 --- a/packages/vue-app/template/mixins/fetch.client.js +++ b/packages/vue-app/template/mixins/fetch.client.js @@ -52,7 +52,15 @@ function created() { } } -async function $fetch() { +function $fetch() { + if (!this._fetchPromise) { + this._fetchPromise = $_fetch.call(this) + .then(() => { delete this._fetchPromise }) + } + return this._fetchPromise +} + +async function $_fetch() { this.<%= globals.nuxt %>.nbFetching++ this.$fetchState.pending = true this.$fetchState.error = null diff --git a/packages/vue-app/template/utils.js b/packages/vue-app/template/utils.js index 3d542ab07c..96d89a87ce 100644 --- a/packages/vue-app/template/utils.js +++ b/packages/vue-app/template/utils.js @@ -638,5 +638,7 @@ export function addLifecycleHook(vm, hook, fn) { if (!vm.$options[hook]) { vm.$options[hook] = [] } - vm.$options[hook].push(fn) + if (!vm.$options[hook].includes(fn)) { + vm.$options[hook].push(fn) + } }