title: Q.js - Using deferred
body: <p>How do I get the value of the text from the example below?</p>
  
  <p>Q.js has an example on using Deferred:</p>
  
  <pre><code>var deferred = Q.defer();
  FS.readFile("foo.txt", "utf-8", function (error, text) {
      if (error) {
          deferred.reject(new Error(error));
      } else {
          deferred.resolve(text);
      }
  });
  return deferred.promise;
  </code></pre>
  
  <p>In this case, there is a node async function being used. What I want to do is get the value of text from the deferred.promise being returned. When I console.log(deferred.promise) I get this:</p>
  
  <pre><code>{ promiseSend: [Function], valueOf: [Function] }
  </code></pre>
  
  <p>What am I doing wrong (as I just copy/pasted the example from here: <a href="https://github.com/kriskowal/q#using-deferreds" rel="noreferrer">https://github.com/kriskowal/q#using-deferreds</a>) or what else do I need to do to actually get that text from the file?</p>
  
  <p>I am aware that node.js has a synchronous version of the call above - my goal is to understand how deferred works with this library.</p>