调用中的额外参数

调用中的额外参数

本文介绍了Alamofire,调用中的额外参数“方法”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我在google上没有运气的答案,我收到此错误调用中的额外参数'method',并指向 .get,但是如果我删除 headers:headers as [[String:Any ] 有用。请帮助I have google some answers with no luck, I got this error "Extra argument 'method' in call" and is pointing at the ".get", but if i remove the "headers : headers as? [String: Any]" it works. Please helplet urlParams:[String : Any] = [ "target": target, "q": textToTranslate, "key": GOOGLE_CLOUD_API_KEY, "source": source] let headers:[String : Any] = ["Content-Type": "application/json", "X-Ios-Bundle-Identifier": Bundle.main.bundleIdentifier as Any] // Fetch Request let urlString = TRANSLATE_API Alamofire.request(urlString, method : .get, parameters : urlParams as? [String: Any], encoding : JSONEncoding.default , headers : headers as? [String: Any]).responseJSON(completionHandler: { (response:DataResponse<Any>) in })推荐答案我将标头:[String:Any]更改为header:[String:String]I changed header:[String : Any] to header:[String : String]let bundleIdentifier = Bundle.main.bundleIdentifier! let headers:[String : String] = ["Content-Type": "application/json", "X-Ios-Bundle-Identifier": bundleIdentifier] 这篇关于Alamofire,调用中的额外参数“方法”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-21 10:43