gpt4 book ai didi

ios - Swift Alamofire 请求错误 - 调用中的额外参数

转载 作者:行者123 更新时间:2023-11-28 15:31:23 27 4
gpt4 key购买 nike

当我尝试使用 Alamofire 请求时出现错误。该错误表明“调用中有一个额外的参数”。

class SwiftStockKit {

class func fetchStocksFromSearchTerm(term: String, completion:@escaping (_ stockInfoArray: [StockSearchResult]) -> ()) {
DispatchQueue.global(priority: DispatchQueue.GlobalQueuePriority.default).async {

let searchURL = "http://autoc.finance.yahoo.com/autoc"

Alamofire.request(.GET, searchURL, parameters: ["query": term, "region": 2, "lang": "en"]).responseJSON { response in

if let resultJSON = response.result.value as? [String : AnyObject] {

if let jsonArray = (resultJSON["ResultSet"] as! [String : AnyObject])["Result"] as? [[String : String]] {

var stockInfoArray = [StockSearchResult]()
for dictionary in jsonArray {
stockInfoArray.append(StockSearchResult(symbol: dictionary["symbol"], name: dictionary["name"], exchange: dictionary["exchDisp"], assetType: dictionary["typeDisp"]))
}

dispatch_async(dispatch_get_main_queue()) {
completion(stockInfoArray: stockInfoArray)
}
}
}
}
}
}

给我错误的行是:

Alamofire.request(.GET, searchURL, parameters: ["query": term, "region": 2, "lang": "en"]).responseJSON { response in

如果有人能解决这个问题,我将不胜感激,谢谢

最佳答案

尝试将您的请求更改为如下内容:

Alamofire.request(searchURL, method: .get, parameters: ["query": term, "region": 2, "lang": "en"], encoding: JSONEncoding.default, headers: nil)

关于ios - Swift Alamofire 请求错误 - 调用中的额外参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44704860/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com