与参数Alamofire GET请求, - >“呼叫额外的参数”

问题描述 投票:1回答:1

我试图让使用Alamofire与参数用Python编写后端的GET请求。

我尝试没有成功这样做的几种方法,我在其他地方见过,我应该为了得到一个干净的GET请求删除参数和它的工作。

我仍然需要使用参数,使我看到了这个帖子:Get JSON result with GET request and parameters with Alamofire

试图在那里的解决方案时,Xcode让我瞬间错误:extra argument in call

这是怎么看起来像当我得到我的错误:

 Alamofire.request(.GET, urlString, parameters: ["test":"te"]).responseJSON {
            (responseObject) -> Void in

            print(responseObject)

            if responseObject.result.isSuccess {
                let resJson = JSON(responseObject.result.value!)
                success(resJson)
            }
            if responseObject.result.isFailure {
                let error: NSError = responseObject.result.error!
                failure(error)
            }
        }
swift get alamofire
1个回答
0
投票

你只需要的参数错误的命令和参数的方法,你忘了写参数名称。

更改此

Alamofire.request(.GET, urlString, parameters: ["test":"te"]).responseJSON {

Alamofire.request(urlString, method: .get, parameters: ["test":"te"]).responseJSON {

您可以随时查询功能参数,当你跳转到它的定义。只需按住Command并单击功能并选择跳转到

enter image description here

现在你可以看到请求的方法参数

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.