Complete the code to mount a router on the '/api' virtual path prefix.
const express = require('express'); const app = express(); const router = express.Router(); app.use([1], router);
The virtual path prefix must start with a slash, so '/api' is correct.
Complete the code to define a GET route on the router for '/users'.
const router = require('express').Router(); router.[1]('/users', (req, res) => { res.send('User list'); });
The GET method is used to define a route that responds to GET requests.
Fix the error in mounting the router so it uses the virtual path prefix '/api'.
const app = require('express')(); const router = require('express').Router(); app.use([1], router);
The first argument to app.use should be the path prefix string, followed by the router.
Fill both blanks to create a router mounted on '/admin' that responds to GET requests at '/dashboard'.
const express = require('express'); const app = express(); const router = express.Router(); router.[1]('/dashboard', (req, res) => { res.send('Admin Dashboard'); }); app.use([2], router);
Use 'get' to define the GET route and '/admin' as the virtual path prefix.
Fill all three blanks to create a router mounted on '/shop' with a POST route at '/order' that sends 'Order received'.
const express = require('express'); const app = express(); const router = express.Router(); router.[1]([2], (req, res) => { res.send('Order received'); }); app.use([3], router);
Use 'post' for the POST route, '/order' as the route path, and mount the router on '/shop'.