Answer the question
In order to leave comments, you need to log in
How to get data from React token jwt?
If the user successfully logged in, I immediately need to get data from this token, how can this be done?
And there is an intermediate handler, can I get the user object from the request and place it in the state?
//middleware
if(!token){
return res.redirect('/')
} else {
const decrypt = jwt.verify(token, process.env.JWT_SECRET)
req.user = {
email: decrypt.email,
role: decrypt.role,
balance: decrypt.balance
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question