Search code examples
swift3alamofire

Cannot call value of non-function type 'HTTPURLResponse?'


I'm trying to make Alamofire request by using this code block

    request = Alamofire.request(imageURL, method: .get)
                        .validate(contentType: ["image/*"])
                        .response(completionHandler: 

{ (request: URLRequest?, response: HTTPURLResponse?, data: NSData?, error: NSError?) -> Void in

but I'm getting the title of this question as a run time error.

How can I overcome this issue?

Thanks in advance...


Solution

  • Instead of using response,data,error independently alamofire provides data which involve all of these parameters

    Solution:

    Alamofire.request(imageURL)
             .validate(contentType: ["image/*"])
             .response { data in
    

    we can access error on data : data.error or response by data.response