Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```js
- const albums = require('express').Router();
- const tracks = require('./tracks').Router();
- //...
- albums.get('/', function(req, res, next) {
- // send our response here
- });
- albums.get('/:albumId', function(req, res, next) {
- let albumId = req.params.albumId;
- // retrieve album from database using albumId
- // send response with album data
- });
- // The fix for our parameters problem
- albums.use('/:albumId/tracks', function(req, res, next) {
- req.albumId = req.params.albumId;
- next()
- }, tracks);
- //...
- module.exports = albums;
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement