mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-30 11:47:54 +01:00
fix: don't discard error in client
This commit is contained in:
@@ -51,16 +51,13 @@ export async function useAsyncQuery<
|
|||||||
): Promise<AsyncData<PickFrom<ReturnType<Transform>, PickKeys>, TError>> {
|
): Promise<AsyncData<PickFrom<ReturnType<Transform>, PickKeys>, TError>> {
|
||||||
const { $client } = useNuxtApp()
|
const { $client } = useNuxtApp()
|
||||||
const key = getQueryKey(pathAndInput)
|
const key = getQueryKey(pathAndInput)
|
||||||
const serverError = useState<TError | null>(`error-${key}`, () => null)
|
|
||||||
const { error, data, ...rest } = await useAsyncData(
|
const { error, data, ...rest } = await useAsyncData(
|
||||||
key,
|
key,
|
||||||
() => $client.query(...pathAndInput),
|
() => $client.query(...pathAndInput),
|
||||||
// @ts-expect-error: Internal
|
// @ts-expect-error: Internal
|
||||||
options,
|
options,
|
||||||
)
|
)
|
||||||
|
const serverError = useState<TError | null>(`error-${key}`, () => error.value)
|
||||||
if (process.server && error.value && !serverError.value)
|
|
||||||
serverError.value = error.value as any
|
|
||||||
|
|
||||||
if (data.value)
|
if (data.value)
|
||||||
serverError.value = null
|
serverError.value = null
|
||||||
|
|||||||
Reference in New Issue
Block a user