mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 23:22:02 +00:00
fix(nuxt): warn to provide a key for useFetch
with transform
option (#4590)
This commit is contained in:
parent
66de7e6c20
commit
7e912e7bf4
@ -141,7 +141,7 @@ export function useAsyncData<
|
||||
|
||||
// Client side
|
||||
if (process.client) {
|
||||
if (fetchOnServer && nuxt.isHydrating) {
|
||||
if (fetchOnServer && nuxt.isHydrating && key in nuxt.payload.data) {
|
||||
// 1. Hydration (server: true): no fetch
|
||||
asyncData.pending.value = false
|
||||
} else if (instance && (nuxt.isHydrating || options.lazy)) {
|
||||
|
@ -28,7 +28,10 @@ export function useFetch<
|
||||
request: Ref<ReqT> | ReqT | (() => ReqT),
|
||||
opts: UseFetchOptions<_ResT, Transform, PickKeys> = {}
|
||||
) {
|
||||
const key = '$f_' + (opts.key || hash([request, opts]))
|
||||
if (process.dev && opts.transform && !opts.key) {
|
||||
console.warn('[nuxt] You should provide a key for `useFetch` when using a custom transform function.')
|
||||
}
|
||||
const key = '$f_' + (opts.key || hash([request, { ...opts, transform: null }]))
|
||||
const _request = computed<FetchRequest>(() => {
|
||||
let r = request
|
||||
if (typeof r === 'function') {
|
||||
|
Loading…
Reference in New Issue
Block a user