From the course: Mastering Nest.js: Build Scalable Applications with Mastery in Nest.js Framework

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Understanding ArgumentMetadata (metadata.data)

Understanding ArgumentMetadata (metadata.data)

When your application receives a request, it comes with various pieces of data, like from the body, from parameters, or from queries. The metadata.data provides crucial information about each of these pieces of data by telling what kind of data it is. This helps the application process them accurately. Let's see an example. So here we have a custom pipe that converts the date to UTC string. And inside the controller, the date is passed to the request body and is getting received at the endpoint. So let's first console.log the metadata.data and make a request from the postman. We already have the request object and when we make the request, the date is converted to UTC string. And if we check the terminal, we get the DOB which is the property we are receiving in the endpoint displayed in the terminal as data. So how is the data property getting DOB as data? The answer is simple. If we look at the body decorator, we have passed the DOB value inside the parentheses. This DOB is part of…

Contents