I created the authentication ( jwt ) and the process is done properly.
I can access the user's information using the following code, but I can't get the user's information using the decorator!
controller :
@Post('/me/info')
@UseGuards(AuthGuard())
myInfo(
@GetUser() user,
@Req() req,
) {
console.log(user); // undefined
console.log(req.user); // get user data object
}
my decorator is:
import { createParamDecorator } from '@nestjs/common';
import { User } from './user.entity';
export const GetUser = createParamDecorator((data, req): User => {
return req.user;
});
what is my code problem ?