mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 07:32:01 +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
|
// Client side
|
||||||
if (process.client) {
|
if (process.client) {
|
||||||
if (fetchOnServer && nuxt.isHydrating) {
|
if (fetchOnServer && nuxt.isHydrating && key in nuxt.payload.data) {
|
||||||
// 1. Hydration (server: true): no fetch
|
// 1. Hydration (server: true): no fetch
|
||||||
asyncData.pending.value = false
|
asyncData.pending.value = false
|
||||||
} else if (instance && (nuxt.isHydrating || options.lazy)) {
|
} else if (instance && (nuxt.isHydrating || options.lazy)) {
|
||||||
|
@ -28,7 +28,10 @@ export function useFetch<
|
|||||||
request: Ref<ReqT> | ReqT | (() => ReqT),
|
request: Ref<ReqT> | ReqT | (() => ReqT),
|
||||||
opts: UseFetchOptions<_ResT, Transform, PickKeys> = {}
|
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>(() => {
|
const _request = computed<FetchRequest>(() => {
|
||||||
let r = request
|
let r = request
|
||||||
if (typeof r === 'function') {
|
if (typeof r === 'function') {
|
||||||
|
Loading…
Reference in New Issue
Block a user