The way to get payload after the guard is like what this tutorial mentioned.
@UseGuards(JwtAuthGuard)
@Get('profile')
getProfile(@Request() req) {
return req.user;
}
Basically, you can access the payload with the object key user
in the request.
But I'd like to know how to store this payload in another key. Is it possible?
you should define a decorator file for getting user:
and use it in controller like this:
you can find documentation here: https://docs.nestjs.com/custom-decorators