Getting the Current User with a Custom Decorator

After setting up our guard and assigning the user to the request object in our application, we need to access this user data in our controllers. This section will explore efficiently retrieving user data using a custom decorator.

Implementation

Suppose we need to directly access user data from the request object in the findBooks method of our BooksController. Let’s see how to do that in the following code:

Get hands-on with 1400+ tech skills courses.