I have the following code to call the server
Alamofire.request(mutableURLRequest)
.responseJSON{ request, response, result in
response in
if let value: AnyObject = response.result.value {
let post = JSON(value)
print(post[0])
}
else
{
print("**ERRO**")
}
}
My question is how do I know if there were any errors in the communication and put a timeout in case it is taking too long.
I have tried the following code to look for possible errors:
Alamofire.request(.GET, URLString, parameters: ["foo": "bar"])
.responseJSON { request, response, result in
switch result {
case .Success(let JSON):
print("Success with JSON: \(JSON)")
case .Failure(let data, let error):
print(error)
}
}
But I get the following error:
Contextual type for closure argument list expects 1 argument, but 3 were specified