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