Swift Api请求错误NSURLErrorDomain代码= -999"已取消"

时间:2018-03-22 11:34:17

标签: swift rest alamofire xcode9

Xcode 9 Swift 4使用tron和swifty尝试http请求

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)

    })
}

获得以下错误:

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()))

0 个答案:

没有答案