答案 0 :(得分:2)
尝试下面的代码
Alamofire.request("Your URL", method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: nil).responseJSON { (response:DataResponse<Any>) in
switch(response.result) {
case .success(_):
break
case .failure(_):
break
}
}
答案 1 :(得分:1)
需要更改代码
encoding:URLEncoding.httpBody
到
encoding:URLEncoding(destination: .httpBody)
在新 Alamofire 4.0
的代码中尝试此操作 Alamofire.request(requestURL, method: .post, parameters: parameters, encoding:URLEncoding(destination: .httpBody), headers: headers)
.responseJSON { response in
switch response.result {
case .success:
self.successGetData(response.result.value! as AnyObject)
case .failure(let error):
print(error)
}
}
来源: - Alamofire 4.0