mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-17 06:01:34 +00:00
fix(vue-app): align client fetch key with server (#8809)
This commit is contained in:
parent
9c24c110b6
commit
e277bb284b
@ -72,7 +72,7 @@ function createdFullStatic() {
|
||||
this._fetchKey = this.$options.fetchKey.call(this, getCounter)
|
||||
} else {
|
||||
const key = 'string' === typeof this.$options.fetchKey ? this.$options.fetchKey : defaultKey
|
||||
this._fetchKey = key + ':' + getCounter(key)
|
||||
this._fetchKey = key ? key + ':' + getCounter(key) : String(getCounter(key))
|
||||
}
|
||||
|
||||
const data = this.<%= globals.nuxt %>._pagePayload.fetch[this._fetchKey]
|
||||
|
@ -54,7 +54,7 @@ export default {
|
||||
this._fetchKey = this.$options.fetchKey.call(this, getCounter)
|
||||
} else {
|
||||
const key = 'string' === typeof this.$options.fetchKey ? this.$options.fetchKey : defaultKey
|
||||
this._fetchKey = key + getCounter(key)
|
||||
this._fetchKey = key ? key + ':' + getCounter(key) : String(getCounter(key))
|
||||
}
|
||||
|
||||
// Added for remove vue undefined warning while ssr
|
||||
|
@ -81,7 +81,7 @@ describe('basic browser', () => {
|
||||
const fetchKeys = await page.evaluate(() => Object.keys(window.__NUXT__.fetch))
|
||||
expect(fetchKeys).toEqual([
|
||||
'0',
|
||||
'DefaultLayout0'
|
||||
'DefaultLayout:0'
|
||||
])
|
||||
expect(await page.$text('div')).toContain('foo-bar-baz')
|
||||
expect(await page.$text('div')).toContain('fizz-buzz')
|
||||
@ -95,7 +95,7 @@ describe('basic browser', () => {
|
||||
const fetchKeys = await page.evaluate(() => Object.keys(window.__NUXT__.fetch))
|
||||
expect(fetchKeys).toEqual([
|
||||
'0',
|
||||
'DefaultLayout0'
|
||||
'DefaultLayout:0'
|
||||
])
|
||||
expect(await page.$text('div')).toContain('foo-bar-baz')
|
||||
expect(await page.$text('div')).toContain('fizz-buzz')
|
||||
@ -108,7 +108,7 @@ describe('basic browser', () => {
|
||||
const fetchKeys = await page.evaluate(() => Object.keys(window.__NUXT__.fetch))
|
||||
expect(fetchKeys).toEqual([
|
||||
'0',
|
||||
'DefaultLayout0',
|
||||
'DefaultLayout:0',
|
||||
'ie0'
|
||||
])
|
||||
expect(await page.$text('button')).toContain('has fetch')
|
||||
@ -120,10 +120,10 @@ describe('basic browser', () => {
|
||||
const fetchKeys = await page.evaluate(() => Object.keys(window.__NUXT__.fetch))
|
||||
expect(fetchKeys).toEqual([
|
||||
'0',
|
||||
'DefaultLayout0',
|
||||
'team0'
|
||||
'DefaultLayout:0',
|
||||
'team:0'
|
||||
])
|
||||
const team = await page.evaluate(() => window.__NUXT__.fetch.team0.team)
|
||||
const team = await page.evaluate(() => window.__NUXT__.fetch['team:0'].team)
|
||||
expect(team.includes('Atinux'))
|
||||
expect(await page.$text('div')).toContain('foo-bar-baz')
|
||||
expect(await page.$text('div')).toContain('fizz-buzz')
|
||||
|
Loading…
Reference in New Issue
Block a user