diff --git a/packages/playground/pages/index.vue b/packages/playground/pages/index.vue index bd56eed..d972881 100644 --- a/packages/playground/pages/index.vue +++ b/packages/playground/pages/index.vue @@ -11,14 +11,13 @@ const addTodo = async () => { const title = Math.random().toString(36).slice(2, 7) try { - const result = await $client.todo.addTodo.mutate({ + const x = await $client.todo.addTodo.mutate({ id: Date.now(), userId: 69, title, completed: false, }) - await result.execute() - console.log('Todo: ', result.data.value) + console.log(x.data.value) } catch (e) { console.log(e) diff --git a/packages/trpc-nuxt/package.json b/packages/trpc-nuxt/package.json index 7287820..cc7ee06 100644 --- a/packages/trpc-nuxt/package.json +++ b/packages/trpc-nuxt/package.json @@ -11,8 +11,8 @@ "import": "./dist/index.mjs" }, "./client": { - "require": "./dist/client.js", - "import": "./dist/client.mjs" + "require": "./dist/client/index.js", + "import": "./dist/client/index.mjs" } }, "main": "./dist/index.js", @@ -37,7 +37,6 @@ "dependencies": { "h3": "^0.8.5", "ohash": "^0.1.5", - "ohmyfetch": "^0.4.20", "ufo": "^0.8.6" }, "devDependencies": { diff --git a/packages/trpc-nuxt/src/client/index.ts b/packages/trpc-nuxt/src/client/index.ts index 453da68..570a7b2 100644 --- a/packages/trpc-nuxt/src/client/index.ts +++ b/packages/trpc-nuxt/src/client/index.ts @@ -1,6 +1,5 @@ import type { CreateTRPCClientOptions, inferRouterProxyClient } from '@trpc/client' import { createTRPCProxyClient } from '@trpc/client' -import { FetchError } from 'ohmyfetch' import type { AnyRouter, } from '@trpc/server' @@ -37,13 +36,6 @@ export function createNuxtProxyDecoration(name: strin const queryKey = getQueryKey(path, input) - if (lastArg === 'mutate') { - return useAsyncDataWithError(queryKey, () => (client as any)[path][lastArg](input), { - ...asyncDataOptions as Record, - immediate: false, - }) - } - return useAsyncDataWithError(queryKey, () => (client as any)[path][lastArg](input), asyncDataOptions) }) } @@ -79,17 +71,3 @@ export function createTRPCNuxtProxyClient(opts: Creat return decoratedClient } - -export function customFetch(input: RequestInfo | URL, options?: RequestInit) { - return globalThis.$fetch.raw(input.toString(), options) - .catch((e) => { - if (e instanceof FetchError && e.response) - return e.response - - throw e - }) - .then(response => ({ - ...response, - json: () => Promise.resolve(response._data), - })) -}