In the code below, Alamofire is complaining that it "Cannot invoke 'responseJSON' with an argument list of type ((_, _, _, _) -> _)." The same issue occurs when using 'response.'
func request(parameters: [String : AnyObject?], completionHandler: ((NSURLRequest, NSHTTPURLResponse?, AnyObject?, NSError?) -> Void)) -> Void {
Alamofire.request(.POST, "localhost:8080/reserve", parameters:
["refreshToken": refreshToken,
"accessToken": accessToken,
"deviceToken": deviceToken],
encoding: .JSON)
.responseJSON { (request, response, data, error) in
completionHandler(request, response, data, error)
}
}
Why is this occuring?
Your parameters
argument is bad typed. It should be [String: AnyObject]?
instead of [String : AnyObject?]
.
Fixing this error, you should be able to compile again.
Otherwise, ensure your token variables exist. If not, the compiler is confused, and the error is not actually due to Alamofire.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With