fix(nuxt): compute fetch cache key with headers (#23462)

This commit is contained in:
Hendrik Heil 2023-10-02 12:31:38 +02:00 committed by GitHub
parent 8b49bc8b3d
commit 3bde91439a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -85,7 +85,7 @@ export function useFetch<
return unref(r) return unref(r)
}) })
const _key = opts.key || hash([autoKey, unref(opts.method as MaybeRef<string | undefined> | undefined)?.toUpperCase() || 'GET', unref(opts.baseURL), typeof _request.value === 'string' ? _request.value : '', unref(opts.params || opts.query)]) const _key = opts.key || hash([autoKey, unref(opts.method as MaybeRef<string | undefined> | undefined)?.toUpperCase() || 'GET', unref(opts.baseURL), typeof _request.value === 'string' ? _request.value : '', unref(opts.params || opts.query), unref(opts.headers)])
if (!_key || typeof _key !== 'string') { if (!_key || typeof _key !== 'string') {
throw new TypeError('[nuxt] [useFetch] key must be a string: ' + _key) throw new TypeError('[nuxt] [useFetch] key must be a string: ' + _key)
} }