mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
fix(vue-app): avoid multiple $fetch
calls (#7129)
Co-authored-by: Aster <duda84@gmail.com>
This commit is contained in:
parent
b82f8d1640
commit
0f27f80c0c
@ -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
|
||||
|
@ -638,5 +638,7 @@ export function addLifecycleHook(vm, hook, fn) {
|
||||
if (!vm.$options[hook]) {
|
||||
vm.$options[hook] = []
|
||||
}
|
||||
if (!vm.$options[hook].includes(fn)) {
|
||||
vm.$options[hook].push(fn)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user