46 Replies
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.
The ??
is called the "nullish coalescing" by the way if you want to google it@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>'.
please shere whole code
I think you might have forget to return user
please use await when you fetching user
@pradeep9339
@pradeep9339
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();
like this
const user = await api.example.getUser.useMutate({ email:credentials?.email ?? "", password: credentials?.password ?? "" }).mutateAsync();
I don't think that's correct
@pradeep9339did you checked?
I'm not trying to modify something I'm trying to get something
btw your code is excuting in server you can just use prisma there
yeah i totally forgot (rusty trpc memories)
did you tried this?
I was just trying to practice trpc this is my first time using it and the T3 stack
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
OK I'm gonna try this method
finger cross
by the way, the old method gives me the values
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
try printing it?
i don't think so it is giving you values
it is giving you values wrapped inside useTRPCQuery
sorry, I have to change the question because the other problems that needs to be resolved for the authentication to actually work
what is that?
most probably because you are useQuery inside server
useQuery is hook
write this query to auth.. function and most probably everything will be resolved
trpc is only for the client
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
I did, but I had a test in college
ohh
try doing what i told you to do
maybe it will start working
this is the Sign page
@pradeep9339
you should go to api/auth/signin right?
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 ...
@pradeep9339
honestly i don't know what are you doing
please follow some tutorial or something
creating a custom signing
with next auth?
Pages | NextAuth.js
NextAuth.js automatically creates simple, unbranded authentication pages for handling Sign in, Sign out, Email Verification and displaying error messages.
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.
this is how i did it
GitHub
striver-sheet-webiste/app/login at main · pradeep800/striver-sheet-...
Contribute to pradeep800/striver-sheet-webiste development by creating an account on GitHub.
are you use app router or page router
T3 stack only page router
okay
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