0
0
Expressframework~10 mins

Mounting routers with app.use in Express - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to mount the router on the '/api' path.

Express
const express = require('express');
const app = express();
const router = require('./router');

app.[1]('/api', router);
Drag options to blanks, or click blank then click option'
Ause
Bget
Cpost
Dlisten
Attempts:
3 left
💡 Hint
Common Mistakes
Using app.get or app.post instead of app.use to mount routers.
Trying to call app.listen instead of mounting the router.
2fill in blank
medium

Complete the code to create a new router instance.

Express
const express = require('express');
const router = express.[1]();
Drag options to blanks, or click blank then click option'
Ause
Brouter
Capp
DRouter
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'router' instead of 'Router'.
Trying to call express.app() or express.use() to create a router.
3fill in blank
hard

Fix the error in mounting the router on the '/users' path.

Express
const express = require('express');
const app = express();
const usersRouter = require('./usersRouter');

app.[1]('/users', usersRouter);
Drag options to blanks, or click blank then click option'
Aget
Bpost
Cuse
Dlisten
Attempts:
3 left
💡 Hint
Common Mistakes
Using app.get or app.post instead of app.use to mount routers.
Trying to call app.listen instead of mounting the router.
4fill in blank
hard

Fill both blanks to mount a router that handles '/products' routes.

Express
const express = require('express');
const app = express();
const [1] = express.Router();

app.[2]('/products', [1]);
Drag options to blanks, or click blank then click option'
AproductsRouter
Buse
Crouter
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using app.get instead of app.use to mount the router.
Using a generic router name instead of a descriptive one.
5fill in blank
hard

Fill all three blanks to create and mount a router for '/orders' routes.

Express
const express = require('express');
const app = express();
const [1] = express.[2]();

app.[3]('/orders', [1]);
Drag options to blanks, or click blank then click option'
AordersRouter
BRouter
Cuse
Drouter
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'router' instead of 'Router' when creating the router.
Using app.get or app.post instead of app.use to mount the router.