let request = AF.request(<Your request>))
request.cURLDescription { (curl) in
print("CURL \(curl)")
}
request.responseJSON { response in
//Do something with your response...
}
request.cURLDescription(calling: { (curl) in
print(curl)
})
以及响应/错误数据:
request.responseDecodable { (response:AFDataResponse<T>) in
switch response.result {
case .success(let value):
var responseMessage : String?
if let data = response.data {
let json = String(data: data, encoding: String.Encoding.utf8)
responseMessage = String(describing: json)
}
print(responseMessage)
break;
case .failure(let error):
var message : String?
if let data = response.data {
let json = String(data: data, encoding: String.Encoding.utf8)
message = String(describing: json)
}
print(message)
break
}
}