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 编码的表单时有效
尝试使用它,作为 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/