title: Node.js function returns undefined
body: <p>I probably have some issues with the asyncness of Node.js.</p>
  
  <h3>rest.js</h3>
  
  <pre><code>var Shred = require("shred");
  var shred = new Shred();
  
  
  module.exports = {
      Request: function (ressource,datacont) {
              var req = shred.get({
                      url: 'ip'+ressource,
                      headers: {
                  Accept: 'application/json',
  
                },
  
                on: {
                  // You can use response codes as events
                  200: function(response) {
                    // Shred will automatically JSON-decode response bodies that have a
                    // JSON Content-Type
                    if (datacont === undefined){
                      return response.content.data;
                      //console.log(response.content.data);
                    }
                    else return response.content.data[datacont];
                  },
                  // Any other response means something's wrong
                  response: function(response) {
                    return "Oh no!";
                  }
                }
              });
      }
  }
  </code></pre>
  
  <h3>other.js</h3>
  
  <pre><code>var rest = require('./rest.js');
  
  console.log(rest.Request('/system'));
  </code></pre>
  
  <p>The problem ist if I call the request from the other.js I always get 'undefined'. If I uncomment the console.log in rest.js then the right response of the http request is written to the console. I think the problem is that the value is returned before the actual response of the request is there. Does anyone know how to fix that?</p>
  
  <p>Best,
  dom</p>