title: AlamoFire GET api request not working as expected
body: <p>I am trying to get learn how to use AlamoFire and I am having trouble.</p>
  
  <p>My method so far is as follows:</p>
  
  <pre><code>func siteInfo()-&gt;String?{
      var info:NSDictionary!
      var str:String!
      Alamofire.request(.GET, MY_API_END_POINT).responseJSON {(request, response, JSON, error) in
          info = JSON as NSDictionary
          str = info["access_key"] as String
          //return str
      }
      return str
  }
  </code></pre>
  
  <p>This returns nil which is a problem. From what I have read <a href="https://stackoverflow.com/questions/25141829/swift-closure-with-alamofire">here</a>, this is because the request can take a while so the closure doesn't execute till after the return. The suggested solution of moving the return into the closure does not work for me and the compiler just yells (adding <code>-&gt;String</code> after <code>(request,response,JSON,error)</code> which gives "'String' is not a subtype of void"). Same goes for the other solution provided.</p>
  
  <p>Any ideas? Even some source code that is not related to this problem, that uses AlamoFire, would be helpful.</p>
  
  <p>Thanks!</p>