Alamofire 4 error request 'extra argument in call'

后端 未结 4 1873
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-28 03:43

I have updated to Xcode8, swift3 and Alamofire 4 and am now getting an error \'extra argument \'method\' in call\' on the below line beginning \'Alamofire.request\'

4条回答
  •  不知归路
    2021-01-28 03:56

    In my case The problem was in the headers argument. It should be [String:String]

    Plus the parameters argument should be [String:Any]

    I used Alamofire 4.8.2 as the below to resolve this compilation error:

    let parameters = ["key":"value","key2":1] as [String:Any]
    let headers = ["header_1":"value"] as [String:String]
    let encoding:URLEncoding = URLEncoding.default
    
    Alamofire.request("base_url",
                       method: .post,
                       parameters: parameters,
                       encoding: encoding,
                       headers: headers) 
    

提交回复
热议问题