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.
Request object - Nest.js Tutorial
From the course: Mastering Nest.js: Build Scalable Applications with Mastery in Nest.js Framework
Request object
In NestJS, there are multiple ways where we can access different parts of an HTTP request. Until now we have seen and used the body decorator. Now the body decorator is used to extract the request body from an incoming HTTP request. Typically, it is used in conjunction with DTO, that is, data transfer objects, to automatically map the incoming request body to a class instance. The body decorator simplifies the process of extracting data from the request body and validating it. Commonly used to extract JSON or form data from the request body. What if we want to access the entire request object rather than the request body only? In that case, Nest provides two decorators, which are request and response decorators. The REQ, that is request decorator, provides direct access to the express request object. by allowing us to access various properties and methods of the incoming HTTP request, such as headers, body, query parameters, etc. It provides more low-level control over the request…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
(Locked)
Understanding controllers5m 10s
-
(Locked)
Controller fundamentals (@Get handler)4m 21s
-
(Locked)
Controller fundamentals (Headers)3m 35s
-
(Locked)
Controller fundamentals (@Post handler)8m 57s
-
(Locked)
Controller fundamentals (@Post handler), part 2 with modules6m 56s
-
(Locked)
Controller fundamentals (fetching params)6m 44s
-
(Locked)
Controller fundamentals (@Put handler)10m 18s
-
(Locked)
Controller fundamentals (@Patch handler)4m 8s
-
(Locked)
Controller fundamentals (@Delete handler)3m 24s
-
(Locked)
Request object4m 42s
-
(Locked)
Response object2m 6s
-
(Locked)
Fetching queries3m 24s
-
(Locked)
@HttpCode vs. @Res decorator3m 22s
-
(Locked)
HTTP response status2m 53s
-
(Locked)
-
-
-
-
-
-
-
-
-
-