Loading

Quipoin Menu

Learn • Practice • Grow

node-js / Handling Routes
mcq
Direction: Choose the correct option

Q1.

How can you check the URL of an incoming request?
A. req.path
B. req.href
C. req.route
D. req.url
Direction: Choose the correct option

Q2.

Which property tells you the HTTP method (GET, POST, etc.)?
A. req.action
B. req.verb
C. req.type
D. req.method
Direction: Choose the correct option

Q3.

How would you route requests for '/about' to a specific handler?
A. Use a routing library
B. Check `req.url` and conditionally respond
C. All of the above
D. Parse the URL
Direction: Choose the correct option

Q4.

What does `url.parse(req.url).pathname` do?
A. Returns the query string
B. Returns the full URL
C. Returns the hostname
D. Returns the path without query parameters
Direction: Choose the correct option

Q5.

To handle POST data, where is the data typically accessed?
A. req.query
B. req.body
C. By listening to 'data' events on the request stream
D. req.data