2

Xcode 9 Swift 4 trying http request using tron and swifty

public func getWaniWifiList(){
    let tron = TRON.init(baseURL: Constants.waniBaseUrl)
    var parameters : [String : String] = [:]
    parameters["version"] = Constants.waniAPIVersion

    let request: APIRequest<WaniRespModel, ErrorModel> = tron.swiftyJSON.request(Constants.waniAPI)
    request.method = .get
    request.parameters = parameters
    request.perform(withSuccess: {response in
        print("error")
    }, failure: {error in

        print(error)

    })
}

Getting below Error:

APIError<ErrorModel>(request: Optional(http://www.i2e1.in/trai/parsexmldata?version=1.0), response: nil, data: Optional(0 bytes), error: Optional(Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLKey=http://www.i2e1.in/trai/parsexmldata?version=1.0, NSErrorFailingURLStringKey=http://www.i2e1.in/trai/parsexmldata?version=1.0, NSLocalizedDescription=cancelled}), errorModel: Optional(SwApp.ErrorModel()))
SaganRitual
  • 3,143
  • 2
  • 24
  • 40
Asheesh
  • 565
  • 6
  • 21
  • Does this help? https://github.com/Alamofire/Alamofire/issues/157 or maybe this: https://stackoverflow.com/questions/33146003/afnetworking-with-request-error-code-999 or https://stackoverflow.com/questions/40447436/alamofire-error-domain-nsurlerrordomain-code-999-cancelled or https://www.google.com/search?rlz=1C5CHFA_enUS688US688&ei=2aSzWurDGYnEjwSOuZyIDA&q=json+NSURLErrorDomain+Code%3D-999+%22cancelled%22&oq=json+NSURLErrorDomain+Code%3D-999+%22cancelled%22&gs_l=psy-ab.3..0i13i30k1j0i13i5i30k1.258619.259002.0.259177.5.5.0.0.0.0.134.134.0j1.1.0....0...1.1.64.psy-ab..4.1.133....0.sDy4FsFe6j0 – SaganRitual Mar 22 '18 at 12:44
  • 1
    If I were to take a guess based on all those links, I'd say your `tron` variable is going out of scope before the request can complete. – SaganRitual Mar 22 '18 at 12:51

0 Answers0