Gavin Beard
Gavin Beard

Reputation: 199

Issue with Alamofire Request

I am trying to use Alamofire to make a web request. It had been working absolutely fine, but after doing a recent pod update it has stopped.

My syntax is:

    var params = [String : Any]()
    if (data != nil) {
        params = try! JSONSerialization.jsonObject(with: data!, options: []) as! [String : Any]
    }

    let _ = Alamofire.request( "http://example.com" , method: Method, parameters: params?, encoding: .queryString, headers: [:]).response{ (request, response, data, error) in
    }

the error looks is "Extra argument 'method' in call" and I don't seem to be able to get rid of it. My parameters of the request to Alamofire.request seem ok to me, but clearly I am missing something.

Upvotes: 1

Views: 393

Answers (1)

Aaron
Aaron

Reputation: 6714

You're not passing anything to the method parameter. I don't know what you're trying to provide in the encoding parameter either but that went through some changes in Alamofire 4.0. For example and for simplicity's sake, this compiles:

let _ = Alamofire.request( "http://example.com" , method: HTTPMethod.get, parameters: nil, encoding: JSONEncoding.default, headers: nil)

Upvotes: 3

Related Questions