title: how to return response to REST api in node js
body: <p>I'm new to Node JS. My node js REST api route code is:</p>
  
  <pre><code>'use strict';
  module.exports = function(app) {
      var sequel = require('../controllers/sampleController');
      app.get('/task?:email', function(req, res){
          res.send(sequel.listByEmail(req.query.email));
      });
  };
  </code></pre>
  
  <p>And my listByEmail function is:</p>
  
  <pre><code>'use strict';
  var apiKey = '1xxxxxxxxL';
  exports.listByEmail = function(emailid) {
      console.log(emailid);
      if(emailid != null &amp;&amp; emailid != undefined) {
          var xyz = require("xyz-api")(apiKey);
          xyz.person.findByEmail(emailid, function(err, data) {
              if(data.status == 200){
                  return data; // data is in json format
              }
          });
      }
  };
  </code></pre>
  
  <p>I returned data like this from that listbyemail function. Data is there, if i try to print the data in console it appears. But while returning the data, it won't returned. It's always return undefined. I can't able to catch the result data from listByEmail function in route and not able to send it as response. Please helpMe!!!</p>