title: Chaining promises in Alamofire using Promisekit
body: <p>I think this is a pretty common use case, but I couldn't find any best way to achieve it.</p>
  
  <p>Some parts of my ios application require login. How do I achieve the following pattern using Alamofire and swift.</p>
  
  <pre><code>.request (.GET 'login_required_endpoint')
        .responsejson(if statusCode == 401){
                  login()
                  continue with GETing
                        login_required_endpoint
  </code></pre>
  
  <p>What is the best way to achieve this.</p>
  
  <ul>
  <li>Make a request</li>
  <li>If server responds with 401(Unauthorized)</li>
  <li>Ask user to login after saving all the request payload for previous request</li>
  <li>After successful login, continue with request in [1] with payload saved</li>
  </ul>
  
  <p>(I realize it is open-ended, but any help on how to make progress would be highly appreciated) </p>