Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. ```js
  2. const albums = require('express').Router();
  3. const tracks = require('./tracks').Router();
  4.  
  5. //...
  6.  
  7. // Our root route to /albums
  8. albums.get('/', function(req, res, next) {
  9. // res.send() our response here
  10. });
  11.  
  12. // A route to handle requests to any individual album, identified by an album id
  13. albums.get('/:albumId', function(req, res, next) {
  14. let albumId = req.params.albumId;
  15. // retrieve album from database using albumId
  16. // res.send() response with album data
  17. });
  18.  
  19. // Note, this route represents /albums/:albumId/tracks because our top-level router is already forwarding /albums to our Albums router!
  20. albums.use('/:albumId/tracks', tracks);
  21.  
  22. //...
  23.  
  24. module.exports = albums;
  25. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement