From b71eaee87992cfda98bcabdf3d3c89295b10dfb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Wed, 12 Feb 2020 16:41:23 +0100 Subject: [PATCH] chore: use data-fetch-key instead of data-ssr-key --- packages/vue-app/template/mixins/fetch.client.js | 6 +++--- packages/vue-app/template/mixins/fetch.server.js | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/vue-app/template/mixins/fetch.client.js b/packages/vue-app/template/mixins/fetch.client.js index 5c866718fe..44bb7e7fa2 100644 --- a/packages/vue-app/template/mixins/fetch.client.js +++ b/packages/vue-app/template/mixins/fetch.client.js @@ -1,7 +1,7 @@ import Vue from 'vue' import { hasFetch, normalizeError, addLifecycleHook } from '../utils' -const isSsrHydration = (vm) => vm.$vnode && vm.$vnode.elm && vm.$vnode.elm.dataset && vm.$vnode.elm.dataset.ssrKey +const isSsrHydration = (vm) => vm.$vnode && vm.$vnode.elm && vm.$vnode.elm.dataset && vm.$vnode.elm.dataset.fetchKey const nuxtState = window.<%= globals.context %> export default { @@ -37,8 +37,8 @@ function created() { // Hydrate component this._hydrated = true - this._ssrKey = +this.$vnode.elm.dataset.ssrKey - const data = nuxtState.fetch[this._ssrKey] + this._fetchKey = +this.$vnode.elm.dataset.fetchKey + const data = nuxtState.fetch[this._fetchKey] // If fetch error if (data && data._error) { diff --git a/packages/vue-app/template/mixins/fetch.server.js b/packages/vue-app/template/mixins/fetch.server.js index a65eec1151..263a25fb4b 100644 --- a/packages/vue-app/template/mixins/fetch.server.js +++ b/packages/vue-app/template/mixins/fetch.server.js @@ -16,13 +16,13 @@ async function serverPrefetch() { // Define an ssrKey for hydration - this._ssrKey = this.$ssrContext.nuxt.fetch.length + this._fetchKey = this.$ssrContext.nuxt.fetch.length - // Add data-ssr-key on parent element of Component + // Add data-fetch-key on parent element of Component const attrs = this.$vnode.data.attrs = this.$vnode.data.attrs || {} - attrs['data-ssr-key'] = this._ssrKey + attrs['data-fetch-key'] = this._fetchKey - // Call asyncData & add to ssrContext for window.__NUXT__.fetch + // Add to ssrContext for window.__NUXT__.fetch this.$ssrContext.nuxt.fetch.push(this.$fetchState.error ? { _error: this.$fetchState.error } : this._data) }