title: Chaining Promises in Coffeescript
body: <p>Is there a way to chain <code>Promises</code> together in Coffeescript. For example, consider the following javascript code,</p>
  
  <pre><code>return $.getJSON('/api/post.json')
    .then(function(response) {
      // do something
    })
    .then(function(response) {
      // do something
    })
    .then(null, function(err) {
      // do something
    });
  </code></pre>
  
  <p>Each of the <code>then's</code> is optional, and the final <code>then</code> needs to be returned by the function.
  Currently I am writing this in coffeescript as,</p>
  
  <pre><code>promise = $.getJSON('/api/post.json')
  promise = promise.then (response) -&gt;
    // do something
  
  promise = promise.then (response) -&gt;
    // do something
  
  promise = promise.then null, (err) -&gt;
    // do something
  
  return promise
  </code></pre>
  
  <p>Is there a better way to do this? Thanks.</p>