fix(nuxt): pass useFetch function name on server for warning (#31213)

Co-authored-by: "solovev.an" <andrey.solovyov.ccs@gmail.com>
This commit is contained in:
John Tanzer 2025-03-07 13:12:26 +02:00 committed by GitHub
parent d5b958ddd7
commit 22f540f861
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -144,7 +144,7 @@ export function useFetch<
watch: watch === false ? [] : [_fetchOptions, _request, ...(watch || [])], watch: watch === false ? [] : [_fetchOptions, _request, ...(watch || [])],
} }
if (import.meta.dev && import.meta.client) { if (import.meta.dev && import.meta.server) {
// @ts-expect-error private property // @ts-expect-error private property
_asyncDataOptions._functionName = opts._functionName || 'useFetch' _asyncDataOptions._functionName = opts._functionName || 'useFetch'
} }
@ -227,7 +227,7 @@ export function useLazyFetch<
) { ) {
const [opts = {}, autoKey] = typeof arg1 === 'string' ? [{}, arg1] : [arg1, arg2] const [opts = {}, autoKey] = typeof arg1 === 'string' ? [{}, arg1] : [arg1, arg2]
if (import.meta.dev && import.meta.client) { if (import.meta.dev && import.meta.server) {
// @ts-expect-error private property // @ts-expect-error private property
opts._functionName ||= 'useLazyFetch' opts._functionName ||= 'useLazyFetch'
} }