diff --git a/packages/nuxt/src/app/composables/fetch.ts b/packages/nuxt/src/app/composables/fetch.ts index d55d7e98dc..59d51141b3 100644 --- a/packages/nuxt/src/app/composables/fetch.ts +++ b/packages/nuxt/src/app/composables/fetch.ts @@ -51,7 +51,7 @@ export function useFetch< if (!request) { throw new Error('[nuxt] [useFetch] request is missing.') } - const key = '$f' + _key + const key = _key === autoKey ? '$f' + _key : _key const _request = computed(() => { let r = request diff --git a/test/basic.test.ts b/test/basic.test.ts index 1a79fea108..cb91e96380 100644 --- a/test/basic.test.ts +++ b/test/basic.test.ts @@ -778,7 +778,7 @@ describe.skipIf(process.env.NUXT_TEST_DEV || isWindows)('payload rendering', () it('renders a payload', async () => { const payload = await $fetch('/random/a/_payload.js', { responseType: 'text' }) expect(payload).toMatch( - /export default \{data:\{\$frand_a:\[[^\]]*\]\},prerenderedAt:\d*\}/ + /export default \{data:\{rand_a:\[[^\]]*\]\},prerenderedAt:\d*\}/ ) })