Extra argument 'method' in call

前端 未结 15 1652
你的背包
你的背包 2020-12-16 08:59

Getting error while calling Alamofire request method in the latest version(4.0.0).

The syntax is:

Alamofire.request(urlString,method: .post, parame         


        
15条回答
  •  隐瞒了意图╮
    2020-12-16 09:38

    Updated for Swift 3:

    let requestString = "https://thawing-inlet-46474.herokuapp.com/charge.php"
            let params = ["stripeToken": token.tokenId, "amount": "200", "currency": "usd", "description": "testRun"]
    
            Alamofire.request(requestString,method: .post, parameters: params, encoding: JSONEncoding.default, headers: [:]).responseJSON { (response:DataResponse) in
    
                switch(response.result) {
                case .success(_):
                    if response.result.value != nil{
                        print("response : \(response.result.value)")
                    }
                    break
    
                case .failure(_):
                    print("Failure : \(response.result.error)")
                    break
    
                }
            }
    

提交回复
热议问题