Alamofire 4 error request 'extra argument in call'

后端 未结 4 1913
佛祖请我去吃肉
佛祖请我去吃肉 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 04:03

    Instead of .json for encoding, try JSONEncoding.default.

    Your paramters should be casted to: [String : Any]?

    This is an issue with compiler which falsely report error for extra argument.

    In the end, your line should look like this:

    Alamofire.request(pulseVoteEndpoint, method: .post, parameters: pulseNewVote as [String : Any]?, encoding: JSONEncoding.default)
             .response { request, response, data, error in
    // rest of the code
    

提交回复
热议问题