mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-14 12:14:40 +01:00
allow passing of other client options
This commit is contained in:
@@ -30,11 +30,12 @@ function createNuxtProxyDecoration<TRouter extends AnyRouter>(name: string, clie
|
||||
|
||||
const path = pathCopy.join('.')
|
||||
|
||||
const [input, asyncDataOptions] = args
|
||||
// @ts-expect-error: Additional options
|
||||
const [input, { trpc, ...asyncDataOptions }] = args
|
||||
|
||||
const queryKey = getQueryKey(path, input)
|
||||
|
||||
return useAsyncDataWithError(queryKey, () => (client as any)[path][lastArg](input), asyncDataOptions)
|
||||
return useAsyncDataWithError(queryKey, () => (client as any)[path][lastArg](input, trpc), asyncDataOptions)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -71,23 +71,18 @@ export function createNuxtApiHandler<TRouter extends AnyRouter>({
|
||||
const path = getPath(event)
|
||||
|
||||
if (path === null) {
|
||||
const error = router.getErrorShape({
|
||||
error: new TRPCError({
|
||||
message:
|
||||
'Param "trpc" not found - is the file named `[trpc]`.ts or `[...trpc].ts`?',
|
||||
code: 'INTERNAL_SERVER_ERROR',
|
||||
}),
|
||||
type: 'unknown',
|
||||
ctx: undefined,
|
||||
path: undefined,
|
||||
input: undefined,
|
||||
})
|
||||
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
statusMessage: JSON.stringify({
|
||||
id: -1,
|
||||
error,
|
||||
error: new TRPCError({
|
||||
message:
|
||||
'Query "trpc" not found - is the file named `[trpc]`.ts or `[...trpc].ts`?',
|
||||
code: 'INTERNAL_SERVER_ERROR',
|
||||
}),
|
||||
type: 'unknown',
|
||||
ctx: undefined,
|
||||
path: undefined,
|
||||
input: undefined,
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user