The last step before testing our logic is to route the incoming request to the new controller function.
- Open the catalogueRouter.js file and include the routing logic shown as follows:
const express = require('express'); module.exports = function (catalogueController) { var router = express.Router(); router.route('/catalogue/artists/:artistId') .get(catalogueController.getArtist) return router; };
The function is called from the server.js file passing the catalogueController as the input object as shown in a previous step. The getArtist controller function is then added to the get() method that will forward the request accordingly using the Router() method that is available ...