title: How should I extract value from Url in Node Js
body: <p>I recently started programming on nodeJs.</p>
  
  <p>I am using Angular JS, resource to call API's as</p>
  
  <pre><code>demoApp.factory('class', function ($resource) {
        return $resource('/class/:classId', { classId: '@_classId' }, {
          update: { method: 'PUT' }
        });
      });
  </code></pre>
  
  <p>And in Controller, I have delete method as;</p>
  
  <pre><code>   // The class object, e {classId: 1, className: "Pro"}
  
  $scope.deleteClass = function (class) {
          var deleteObj = new Class();
          deleteObj.classId = class.classId;
          deleteObj.$delete({classId : deleteObj.classId}, function() {
              growl.success("Class deleted successfully.");
              $location.path('/'); 
              },function () {
                  growl.error("Error while deleting Class.");
              }
          ); 
      };
  </code></pre>
  
  <p>Using browser, I verified call goes to : </p>
  
  <pre><code>http://localhost:3000/class/1
  </code></pre>
  
  <p>Now in node Js, How should I extract value from Url,</p>
  
  <p>In server.js</p>
  
  <pre><code>app.use('/class', classController.getApi);
  </code></pre>
  
  <p>In classController.js</p>
  
  <pre><code>exports.getApi = function(req, resp){
      switch(req.method) {
          case 'DELETE':
              if (req) {
                  // how to extract 1 from url.
              }
              else {
                  httpMsgs.show404(req, resp);
              }
              break;        
  </code></pre>
  
  <p>I have tried , </p>
  
  <pre><code>console.log(req.params);
  console.log(req.query);
  </code></pre>
  
  <p>But no luck.</p>
  
  <p>I am seeing </p>
  
  <pre><code>    console.log(req._parsedUrl);
  query: null,
  pathname: '/class/1',
  path: '/class/1',
  </code></pre>
  
  <p>Any help appreciated. </p>