I'm not really sure how to deal with this. It's a type problem.

46 Replies
Vincent Udén
Vincent Udén15mo ago
The query won't accept a value which might be null or undefined (which the values you are passing in might be). In order to avoid passing null you can provide a fallback-value using the ?? operator.
/* ... */ .useQuery({ email: credentials?.email ?? "", password: credentials?.password ?? "" })
/* ... */ .useQuery({ email: credentials?.email ?? "", password: credentials?.password ?? "" })
The ?? is called the "nullish coalescing" by the way if you want to google it
gave_one
gave_one15mo ago
@Vincent new error Type '(credentials: Record<"email" | "password", string> | undefined, req: Pick<RequestInternal, "query" | "headers" | "body" | "method">) => { ...; } | ... 1 more ... | undefined' is not assignable to type '(credentials: Record<"email" | "password", string> | undefined, req: Pick<RequestInternal, "query" | "headers" | "body" | "method">) => Awaitable<...>'. Type '{ id: string; name: string | null; email: string | null; password: string | null; emailVerified: Date | null; image: string | null; } | null | undefined' is not assignable to type 'Awaitable<User | null>'. Type 'undefined' is not assignable to type 'Awaitable<User | null>'.
gave_one
gave_one15mo ago
pradeep
pradeep15mo ago
please shere whole code I think you might have forget to return user please use await when you fetching user
gave_one
gave_one15mo ago
@pradeep9339
gave_one
gave_one15mo ago
gave_one
gave_one15mo ago
@pradeep9339
pradeep
pradeep15mo ago
reather then useQuery try using useMuatate and then use asyncMutate(i am not sure about name but it start with async ) const user=await api.example.getUser.useMutate(...datat).mutateAsync();
gave_one
gave_one15mo ago
like this const user = await api.example.getUser.useMutate({ email:credentials?.email ?? "", password: credentials?.password ?? "" }).mutateAsync(); I don't think that's correct @pradeep9339
pradeep
pradeep15mo ago
did you checked?
gave_one
gave_one15mo ago
I'm not trying to modify something I'm trying to get something
pradeep
pradeep15mo ago
btw your code is excuting in server you can just use prisma there yeah i totally forgot (rusty trpc memories) did you tried this?
gave_one
gave_one15mo ago
I was just trying to practice trpc this is my first time using it and the T3 stack
pradeep
pradeep15mo ago
i never used trpc aside from component so i am not sure how to it but don't try to use trpc everywhere if it is simple query like yours just use db reather then make another end point for it
gave_one
gave_one15mo ago
OK I'm gonna try this method
pradeep
pradeep15mo ago
finger cross
gave_one
gave_one15mo ago
by the way, the old method gives me the values
gave_one
gave_one15mo ago
should I just stick with it? @pradeep9339 a lot of things are broken so I have to fix them one by one T3 stack is confusing
pradeep
pradeep15mo ago
try printing it? i don't think so it is giving you values it is giving you values wrapped inside useTRPCQuery
gave_one
gave_one15mo ago
sorry, I have to change the question because the other problems that needs to be resolved for the authentication to actually work
pradeep
pradeep15mo ago
what is that?
gave_one
gave_one15mo ago
pradeep
pradeep15mo ago
most probably because you are useQuery inside server useQuery is hook write this query to auth.. function and most probably everything will be resolved
gave_one
gave_one15mo ago
trpc is only for the client
pradeep
pradeep15mo ago
most probably useQuery use something which should not called in server btw you are also not using await here please first watch or read documentation before going through trpc
gave_one
gave_one15mo ago
I did, but I had a test in college
pradeep
pradeep15mo ago
ohh try doing what i told you to do maybe it will start working
gave_one
gave_one15mo ago
gave_one
gave_one15mo ago
this is the Sign page
gave_one
gave_one15mo ago
gave_one
gave_one15mo ago
@pradeep9339
pradeep
pradeep15mo ago
you should go to api/auth/signin right?
pradeep
pradeep15mo ago
https://youtu.be/2kgqPvs0j_I?t=1060 if possible maybe watch this
Build SaaS with Ethan
YouTube
Set up Next-Auth with Next.js and Prisma with this ultimate guide!
This is the ULTIMATE guide for setting up Next Auth with the credential provider and Prisma. Check out my other video for setting up Prisma and then dive in to hook it all up. Learn how to protect routes, get session information, and configure everything so you can fully use Next Auth. ALL IN THE APP DIRECTORY! Let's go! 🔖 Chapters 🔖 00:00 ...
gave_one
gave_one15mo ago
gave_one
gave_one15mo ago
@pradeep9339
pradeep
pradeep15mo ago
honestly i don't know what are you doing please follow some tutorial or something
gave_one
gave_one15mo ago
creating a custom signing
pradeep
pradeep15mo ago
with next auth?
gave_one
gave_one15mo ago
Pages | NextAuth.js
NextAuth.js automatically creates simple, unbranded authentication pages for handling Sign in, Sign out, Email Verification and displaying error messages.
pradeep
pradeep15mo ago
GitHub
striver-sheet-webiste/lib/auth.ts at main · pradeep800/striver-shee...
Contribute to pradeep800/striver-sheet-webiste development by creating an account on GitHub.
pradeep
pradeep15mo ago
this is how i did it
pradeep
pradeep15mo ago
GitHub
striver-sheet-webiste/app/login at main · pradeep800/striver-sheet-...
Contribute to pradeep800/striver-sheet-webiste development by creating an account on GitHub.
pradeep
pradeep15mo ago
are you use app router or page router
gave_one
gave_one15mo ago
T3 stack only page router
pradeep
pradeep15mo ago
okay
gave_one
gave_one15mo ago
I will just create another question pool and see if other people know what to do @pradeep9339 your assistance was amazing. Thank you for now weirdLeave
Want results from more Discord servers?
Add your server