title: Node/Express function and callback are not breaking with return
body: <p>I am creating a 'refresh data' function in Node and I cannot figure out where to place the callbacks and returns.  The function continues to run.  Below is a list of things the function should do.  Could someone help out?</p>
  
  <ol>
  <li>Check if a user has an api id in the local MongoDB</li>
  <li>Call REST api with POST to receive token</li>
  <li>Store token results in a MongoDB</li>
  <li>Terminate function</li>
  </ol>
  
  <p>./routes/index.js</p>
  
  <pre><code>router.post('/refresh', function(req, res) {
      var refresh = require('../api/refresh');
      refresh(req, function() { return console.log('Done'); });
  });
  </code></pre>
  
  <p>../api/refresh.js</p>
  
  <pre><code>var callToken = require('./calltoken');
  var User = require('../models/user'); // Mongoose Schema
  
  module.exports = function(req, callback) {
    User.findOne( {'username':req.body.username}, function(err, user) {
      if(err) { console.log(err) }
      if (user.api_id == 0) {
        callToken.postToken(req.body.username, callback);
      } else { // Do something else }
    });
  };
  </code></pre>
  
  <p>./calltoken.js</p>
  
  <pre><code>var request = require('request');
  var Token = require('../models/token');  // Mongoose Schema
  
  module.exports = {
  
    postToken: function(user, callback) {
      var send = {method:'POST', url:'address', formData:{name:user} };
      request(send, function(err, res, body) {
        if(err) { console.log(err) }
        if (res.statusCode == 201) { 
          var newToken = new Token();
          newToken.token = JSON.parse(body).access_token['token'];
          newToken.save(function(err) {
            if(err) { console.log(err) }
            return callback();
          });
        }
      });
    }
  };
  </code></pre>