From f09d1d88daa81afe4dce80861ab238b258cafce8 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 6 Jul 2022 20:09:46 +0100 Subject: [PATCH] fix(nuxt): update `useFetch` key warning to include any function or blob (#5710) * fix(nuxt): update `useFetch` key warning to include any function or blob * Update packages/nuxt/src/app/composables/fetch.ts Co-authored-by: pooya parsa --- packages/nuxt/src/app/composables/fetch.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nuxt/src/app/composables/fetch.ts b/packages/nuxt/src/app/composables/fetch.ts index 0ff307c232..2d52a096ec 100644 --- a/packages/nuxt/src/app/composables/fetch.ts +++ b/packages/nuxt/src/app/composables/fetch.ts @@ -26,8 +26,8 @@ export function useFetch< request: Ref | ReqT | (() => ReqT), opts: UseFetchOptions<_ResT, Transform, PickKeys> = {} ) { - if (process.dev && opts.transform && !opts.key) { - console.warn('[nuxt] You should provide a key for `useFetch` when using a custom transform function.') + if (process.dev && !opts.key && Object.values(opts).some(v => typeof v === 'function' || v instanceof Blob)) { + console.warn('[nuxt] [useFetch] You should provide a key when passing options that are not serializable to JSON:', opts) } const key = '$f_' + (opts.key || hash([request, { ...opts, transform: null }])) const _request = computed(() => {