Q:

Swift Alamofire: Error - 999

I am doing reuquest inside another request and get error -999 on the second one. I need this to keep same cookies received in first session and also because second request is optional.
let configuration = URLSessionConfiguration.default
let sessionManager = Alamofire.SessionManager(configuration: configuration)

sessionManager.request( NSLocalizedString("url_login", comment: ""), method: .post, parameters: params).response{ response in
    if response.response?.statusCode == 200 {
            /..some elaboration../
            if(/..condition../){
            self.showMessage(message: "OK")
            sessionManager.request( NSLocalizedString("url_checkUserType", comment: ""), method: .get).responseJSON(){ response in
                 /..HERE I GET: finished with error - code: -999 ../
                 }

     }else{
            /..some other code../
          }
}

A:

The problem was that variables sessionManager  and NSLocalizedString where not reachable from the launched thread. Solution make these variables global inside Controller and call them in the launched thread using self..
Note that session manager should be declared like:
var sessionManager = Alamofire.SessionManager(configuration: URLSessionConfiguration.default)

