title: Call own method from module async
body: <p>I have my <code>app.js</code>, which has the following endpoint. This endpoint obviously acts weird, because it expects data to return before it says <code>res.send(data)</code>, which is the wrong way to do Node.js.</p>
  
  <p>I am not sure how to modify my code, so I get the data from <code>users.GetUsers</code>, and can send it to the client <code>with res.send(data)</code>.</p>
  
  <p><strong>App.js code</strong>:</p>
  
  <pre><code>var http = require('http');
  var express = require('express');
  var users = require('./users');
  
  client = redis.createClient();
  var app = express();
  var port = 4000;
  
  app.listen(port);
  
  app.get('/users',function(req,res) {
      var data = users.getUsers(req,res);
      console.log('data: ' + data);
      res.send(data);
  });
  </code></pre>
  
  <p><strong>My users module</strong>:</p>
  
  <pre><code>var mongoose = require('mongoose');
  var redis = require('redis');
  client = redis.createClient();
  
  exports.getUsers = function(req,res) {
      var cacheKey = 'userKey';
  
      //client.del(cacheKey);
  
      client.get(cacheKey,function(err,data) {
          if(err || data === null) {
              mongoose.model('users').find(function(err,users) {
                  console.log('Setting cache: ' + cacheKey);
                  client.set(cacheKey,users,redis.print);
                  return users;
              });
          } else {
              console.log('Find data in cache');
              return data;
          }
      });
  };
  </code></pre>
  
  <p><strong>My problem</strong>:</p>
  
  <p>My variable <code>data</code> in <code>App.js</code>, will always be undefined. How do I modify my call, so I can get the data to the server when it is ready?</p>