mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
fix(nuxt)!: include request url and params in useFetch
key (#6632)
This commit is contained in:
parent
bc097a6e26
commit
f7850526e8
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user