Next.js Discord

Discord Forum

UserId from jwt token or form data?

Answered
Iridescent shark posted this in #help-forum
Open in Discord
Avatar
Iridescent sharkOP
I have endpoint to create new tag item, and each item has userId that creates it. My question is should I send userId in body on client or can I use userId from jwt token that I send along with request? Which way is more common?
Answered by B33fb0n3
I would do it with the jwt token. Like this you are way more flexible: you can verify it, trust the payload, get data, ...
View full answer

3 Replies

Avatar
B33fb0n3
I would do it with the jwt token. Like this you are way more flexible: you can verify it, trust the payload, get data, ...
Answer
Avatar
B33fb0n3
@Iridescent shark
if (solved) {
   await markAsSolution();
} else {
   throw new Error("What's missing to solve your question?")?
}