Step 7 – define the controller function

In this step the controller function is created that calls the getArtist in the data layer and returns the response using REST:

  1. Open the controller file catalogueController.js, create a new function getArtist, and implement the logic to call the getArtist as part of the data layer and return the correct response. Please see a snapshot of the following code:
      controller.getArtist = function (request, response) {        data.getArtist(request.params.artistId, function(result){          var index;          var albums;          try{            //Loop through each album and songs to include            //HAL and to capture the fields required in the JSON            //response to the Client i.e. the MongoDB document            //version field is not returned. for(index = 0; index ...

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.