diff --git a/packages/nuxt/src/app/composables/fetch.ts b/packages/nuxt/src/app/composables/fetch.ts index dfd2bbc8e29..5c17ab5e35f 100644 --- a/packages/nuxt/src/app/composables/fetch.ts +++ b/packages/nuxt/src/app/composables/fetch.ts @@ -1,6 +1,7 @@ import type { FetchError, FetchOptions } from 'ofetch' import type { TypedInternalResponse, NitroFetchRequest } from 'nitropack' import { computed, unref, Ref, reactive } from 'vue' +import { hash } from 'ohash' import type { AsyncDataOptions, _Transform, KeyOfRes, AsyncData, PickFrom } from './asyncData' import { useAsyncData } from './asyncData' @@ -44,7 +45,7 @@ export function useFetch< arg2?: string ) { const [opts = {}, autoKey] = typeof arg1 === 'string' ? [{}, arg1] : [arg1, arg2] - const _key = opts.key || autoKey + const _key = opts.key || hash([autoKey, unref(opts.baseURL), typeof request === 'string' ? request : '', unref(opts.params)]) if (!_key || typeof _key !== 'string') { throw new TypeError('[nuxt] [useFetch] key must be a string: ' + _key) }