Step 8 – route the incoming request to the new controller function

The last step before testing our logic is to route the incoming request to the new controller function.

  1. 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 ...

Get Implementing Oracle API Platform Cloud Service now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.