Node.js Authentication & JWT Quiz – 20 Questions with Answers
20 questions · 15 min · Medium
Test your knowledge of Express.js basics and routing in Node.js, including creating servers, routes, HTTP methods, middleware, request and response objects, route parameters, query strings, and route handlers.
No sign-up needed · Last updated:
Score: 0 00:00
Create a free account to keep your scores and track your progress. It is optional.
20 questions · 15 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
A. A web framework for Node.js
Express.js is a lightweight web application framework for Node.js commonly used to build web servers and APIs.
A. npm install express
The npm install express command installs Express.js as a dependency in the current Node.js project.
A. const app = express()
Calling the imported express function creates an Express application instance.
A. app.get()
The app.get() method defines a route that responds to HTTP GET requests.
A. app.post()
The app.post() method defines a route handler for HTTP POST requests.
A. req
The request object, commonly named req, contains information such as parameters, query strings, headers, and the request body.
A. res
The response object, commonly named res, provides methods such as res.send() and res.json() for sending responses.
A. res.json()
The res.json() method sends a JSON response to the client.
A. /users/:id
Express uses a colon before a parameter name, such as /users/:id. The value can then be accessed through req.params.id.
A. req.params
Route parameters such as :id are available through the req.params object.
A. req.query.category
Query string values are available through req.query, so category can be accessed using req.query.category.
A. A function that has access to the request, response, and next middleware function
Express middleware functions can inspect or modify requests and responses, end the request-response cycle, or pass control to the next middleware.
A. next()
Calling next() passes control to the next middleware function in the request processing chain.
A. app.use()
The app.use() method can mount middleware or an Express Router at a specified path, such as app.use('/api', router).
A. PUT
PUT is commonly used to replace or completely update an existing resource, while PATCH is commonly used for partial updates.