I'm using Alamofire for my http requests but I'm not able to get error message from requests that don't pass validation
Alamofire.request(method, url, headers: headers, parameters: parameters, encoding: encoding)
.validate(statusCode: 200..<300)
.responseJSON { response in
switch response.result {
case .Success:
// response.result.value returns JSON
case .Failure(let error):
// response.result.value returns nil
}
}
How can I get data (JSON) if I get error code 400 and others. The API is sending the data in body even if the request was not successful.