SharpieMaster
SharpieMaster
TtRPC
Created by SharpieMaster on 9/26/2023 in #❓-help
trpc error fetch failed
Error:
new recipe
>> mutation #1 recipe.create { input: { title: 'title', description: 'description' } }
<< mutation #1 recipe.create {
input: { title: 'title', description: 'description' },
result: TRPCClientError: fetch failed
at TRPCClientError.from (webpack-internal:///(rsc)/./node_modules/.pnpm/@trpc+client@10.37.1_@trpc+server@10.37.1/node_modules/@trpc/client/dist/TRPCClientError-fef6cf44.mjs:30:16)
at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@trpc+client@10.37.1_@trpc+server@10.37.1/node_modules/@trpc/client/dist/httpBatchLink-520db465.mjs:207:101) {
meta: undefined,
shape: undefined,
data: undefined,
[cause]: TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11576:11) {
cause: [RequestContentLengthMismatchError]
}
},
elapsedMs: 14
}
- error node_modules\.pnpm\@trpc+client@10.37.1_@trpc+server@10.37.1\node_modules\@trpc\client\dist\TRPCClientError-fef6cf44.mjs (26:15) @ TRPCClientError.from
- error TRPCClientError: fetch failed
null
new recipe
>> mutation #1 recipe.create { input: { title: 'title', description: 'description' } }
<< mutation #1 recipe.create {
input: { title: 'title', description: 'description' },
result: TRPCClientError: fetch failed
at TRPCClientError.from (webpack-internal:///(rsc)/./node_modules/.pnpm/@trpc+client@10.37.1_@trpc+server@10.37.1/node_modules/@trpc/client/dist/TRPCClientError-fef6cf44.mjs:30:16)
at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@trpc+client@10.37.1_@trpc+server@10.37.1/node_modules/@trpc/client/dist/httpBatchLink-520db465.mjs:207:101) {
meta: undefined,
shape: undefined,
data: undefined,
[cause]: TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11576:11) {
cause: [RequestContentLengthMismatchError]
}
},
elapsedMs: 14
}
- error node_modules\.pnpm\@trpc+client@10.37.1_@trpc+server@10.37.1\node_modules\@trpc\client\dist\TRPCClientError-fef6cf44.mjs (26:15) @ TRPCClientError.from
- error TRPCClientError: fetch failed
null
8 replies
TtRPC
Created by SharpieMaster on 9/26/2023 in #❓-help
trpc error fetch failed
recipe router:
import { z } from "zod";

import {
createTRPCRouter,
protectedProcedure,
publicProcedure,
} from "~/server/api/trpc";

export const recipeRouter = createTRPCRouter({
create: protectedProcedure
.input(z.object({ title: z.string(), description: z.string() }))
.mutation(async ({ ctx, input }) => {
const recipe = await ctx.db.recipe.create({
data: {
title: input.title,
description: input.description,
userId: ctx.session.user.id,
},
});

return recipe;
}),

hello: publicProcedure
.input(z.object({ message: z.string() }))
.query(({ ctx, input }) => {
return "hello" + input.message;
}),
});
import { z } from "zod";

import {
createTRPCRouter,
protectedProcedure,
publicProcedure,
} from "~/server/api/trpc";

export const recipeRouter = createTRPCRouter({
create: protectedProcedure
.input(z.object({ title: z.string(), description: z.string() }))
.mutation(async ({ ctx, input }) => {
const recipe = await ctx.db.recipe.create({
data: {
title: input.title,
description: input.description,
userId: ctx.session.user.id,
},
});

return recipe;
}),

hello: publicProcedure
.input(z.object({ message: z.string() }))
.query(({ ctx, input }) => {
return "hello" + input.message;
}),
});
8 replies
TtRPC
Created by SharpieMaster on 9/26/2023 in #❓-help
trpc error fetch failed
components/NewRecipeButton.tsx
"use client";

import { FC } from "react";

interface NewRecipeButtonProps {
onClick: () => Promise<void>;
}

const NewRecipeButton: FC<NewRecipeButtonProps> = ({ onClick }) => {
return (
<button
onClick={async () => {
await onClick();
}}
>
new recipe
</button>
);
};

export default NewRecipeButton;
"use client";

import { FC } from "react";

interface NewRecipeButtonProps {
onClick: () => Promise<void>;
}

const NewRecipeButton: FC<NewRecipeButtonProps> = ({ onClick }) => {
return (
<button
onClick={async () => {
await onClick();
}}
>
new recipe
</button>
);
};

export default NewRecipeButton;
8 replies
TtRPC
Created by SharpieMaster on 9/26/2023 in #❓-help
trpc error fetch failed
account/page.tsx
import { redirect } from "next/navigation";
import React from "react";
import NavBar from "~/components/NavBar";
import NewRecipeButton from "~/components/NewRecipeButton";
import { api } from "~/trpc/server";

const AccountPage = () => {
return (
<div>
<NavBar />
<NewRecipeButton onClick={newRecipe} />
</div>
);
};

const newRecipe = async () => {
"use server";

console.log("new recipe");

const newRecipe = await api.recipe.create.mutate({
title: "title",
description: "description",
});

console.log(newRecipe);
};

export default AccountPage;
import { redirect } from "next/navigation";
import React from "react";
import NavBar from "~/components/NavBar";
import NewRecipeButton from "~/components/NewRecipeButton";
import { api } from "~/trpc/server";

const AccountPage = () => {
return (
<div>
<NavBar />
<NewRecipeButton onClick={newRecipe} />
</div>
);
};

const newRecipe = async () => {
"use server";

console.log("new recipe");

const newRecipe = await api.recipe.create.mutate({
title: "title",
description: "description",
});

console.log(newRecipe);
};

export default AccountPage;
8 replies