Loading

Quipoin Menu

Learn • Practice • Grow

express-js / Express.js Request & Response
mcq
Direction: Choose the correct option

Q1.

Which property of the request object contains the HTTP method (GET, POST, etc.)?
A. req.route
B. req.method
C. req.url
D. req.path
Direction: Choose the correct option

Q2.

How do you send a JSON response using the response object?
A. res.sendJSON()
B. res.jsonp()
C. res.json()
D. res.send()
Direction: Choose the correct option

Q3.

What does res.redirect('/home') do?
A. Renders a view
B. Sends a file
C. Redirects the client to '/home' with a 302 status
D. Serves the home page
Direction: Choose the correct option

Q4.

How can you get the value of a specific header from the request?
A. req.get('Header-Name')
B. req.headers['Header-Name']
C. Both A and B
D. req.header('Header-Name')
Direction: Choose the correct option

Q5.

What is the purpose of res.status()?
A. To log the status
B. To set the HTTP status code for the response
C. To get the status code of the request
D. To check if the response is successful