This commit is contained in:
wobsoriano
2022-12-18 16:14:59 -08:00
parent b1ddfc146b
commit 491c04739a
2 changed files with 9 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
import { createTRPCProxyClient, httpBatchLink, loggerLink } from '@trpc/client'
import { httpBatchLink, loggerLink } from '@trpc/client'
import superjson from 'superjson'
import { FetchError } from 'ofetch'
import { createTRPCNuxtClient } from 'trpc-nuxt/client'
@@ -10,18 +10,18 @@ export default defineNuxtPlugin(() => {
transformer: superjson,
links: [
// adds pretty logs to your console in development and logs errors in production
// loggerLink({
// enabled: opts =>
// process.env.NODE_ENV === 'development' ||
// (opts.direction === 'down' && opts.result instanceof Error)
// }),
loggerLink({
enabled: opts =>
process.env.NODE_ENV === 'development' ||
(opts.direction === 'down' && opts.result instanceof Error)
}),
httpBatchLink({
url: '/api/trpc',
headers () {
return headers
},
fetch: (input, options) =>
$fetch.raw(input.toString(), options)
globalThis.$fetch.raw(input.toString(), options)
.catch((e) => {
if (e instanceof FetchError && e.response) { return e.response }
throw e

View File

@@ -1,11 +1,11 @@
import { type CreateTRPCClientOptions, type inferRouterProxyClient, createTRPCProxyClient, httpBatchLink as _httpBatchLink } from '@trpc/client'
import { type CreateTRPCClientOptions, type inferRouterProxyClient, createTRPCProxyClient } from '@trpc/client'
import { type AnyRouter } from '@trpc/server'
import { createFlatProxy, createRecursiveProxy } from '@trpc/server/shared'
import { hash } from 'ohash'
import { nanoid } from 'nanoid'
import { type DecoratedProcedureRecord } from './types'
// @ts-expect-error: Nuxt auto-imports
import { getCurrentInstance, onScopeDispose, useAsyncData, useRequestHeaders, ref, unref } from '#imports'
import { getCurrentInstance, onScopeDispose, useAsyncData, ref, unref } from '#imports'
/**
* Calculates the key used for `useAsyncData` call