-1
jwt.verify(token,process.env.SECRETKEY, function(err,decodedToken){

      console.log(decodedToken);

    })
Console output
{ email: 'm.blal@gmail.com', iat: 1601341321 }

how can I read the value of email from decoded token?

Ahmed Ali
  • 37
  • 6

1 Answers1

0

Attach the email to the request, then you can access that value from the controller

jwt.verify(token,process.env.SECRETKEY, function(err,decodedToken){
      if(err) throw new ForbiddenException('Invalid token'); 
      req.user = decodedToken //Attach token payload to request
    })

You can use that value later on the controller using req.user or creating a decorator (I prefer this).

Juan Rambal
  • 573
  • 2
  • 6