我有以下代码:
let parameters: [String: String] = [
"make" : "",
"style" : "3"
]
if let storedToken = UserDefaults.standard.string(forKey: Constants.userDefaults.kToken) {
Alamofire.request(Constants.Endpoints.kGetVehicles, method: HTTPMethod.get, parameters: parameters, encoding: JSONEncoding.default, headers: ["Authorization": "JWT \(storedToken)"]).responseJSON { response in
if let requestResponseJson = response.result.value {
let requestResponseObject:Dictionary = requestResponseJson as! Dictionary<String, Any>
print("--------------------------")
if let vehicleid:String = requestResponseObject["vehicleid"] as? String {
} else {
self.view.hideToastActivity()
var style = ToastStyle()
style.messageColor = Constants.Colors.classyGreen
style.messageAlignment = .center
ToastManager.shared.style = style
self.view.makeToast("Something bad happened", duration: 3.0, position: .center, style: style) // now uses the shared style
ToastManager.shared.isTapToDismissEnabled = true
}
}
}
}
从viewDidLoad()调用
但是请求超时并显示以下错误
Error Domain=kCFErrorDomainCFNetwork Code=-1001