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 <pyapar@gmail.com>
This commit is contained in:
Daniel Roe 2022-07-06 20:09:46 +01:00 committed by GitHub
parent 490d686fe6
commit f09d1d88da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,8 +26,8 @@ export function useFetch<
request: Ref<ReqT> | 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(() => {