Complete the code to create a router instance.
const express = require('express'); const router = express.[1]();
The Router() method creates a new router object to handle routes.
Complete the code to prefix all routes in the router with '/api'.
app.use([1], router);The app.use('/api', router) prefixes all routes in the router with '/api'.
Fix the error in the route definition to respond with 'Hello World'.
router.get('/hello', (req, res) => { res.[1]('Hello World'); });
The res.send() method sends a response body as a string.
Fill both blanks to create a router that handles GET requests at '/users' and responds with JSON.
router.[1]('/users', (req, res) => { res.[2]({ message: 'User list' }); });
The get method defines a GET route, and json sends a JSON response.
Fill all three blanks to prefix routes with '/api', create a POST route at '/login', and send a JSON response.
app.use([1], router); router.[2]('/login', (req, res) => { res.[3]({ success: true }); });
Prefix routes with '/api', define a POST route, and send JSON response.
