gpt4 book ai didi

ios - alamofire post 方法中的 response.result.value 为 nil

转载 作者:搜寻专家 更新时间:2023-10-31 22:41:50 24 4
gpt4 key购买 nike

        let parametersDictionary = [
"email" : "name@gmail.com",
"password" : "password"
]
Alamofire.request("http://nanosoftech.com/store/user_check", method: .post, parameters: (parametersDictionary as NSDictionary) as? Parameters , encoding: JSONEncoding.default, headers: nil).responseJSON { response in
print("response:", response.result.value)
}

我在 post 方法 api 中工作,上面的代码不起作用。我没有得到任何回应。但是这个 url 在 postman 和 android studio 中也能正常工作。这个问题背后的原因是什么?

最佳答案

您的 url 仅在请求使用 url 编码的表单时有效

enter image description here

尝试使用它,作为 documented在 GitHub 上

Alamofire.request("http://nanosoftech.com/store/user_check", method: .post, parameters: parametersDictionary , encoding: URLEncoding.default)

如果此编码不起作用,请尝试编码:URLEncoding.httpBody

关于ios - alamofire post 方法中的 response.result.value 为 nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44954917/

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