Alamofire POST方法不会将值传递给url

sha*_*ria 0 post ios swift alamofire

我在我的应用程序中使用Alamofire进行网络连接.在Alamofire中,我正在编写POST方法将值传递给url,但它没有传递任何值.显示为null.以下是我的代码:

let parameters = ["username": "\(textField.text)"]
let urlString = "**Some URL**"
Alamofire.request(.POST, urlString, parameters: parameters, encoding: .JSON).responseJSON { response in 
    guard response.result.error == nil else {
        print("error calling POST on email API")
        print(response.result.error!)
        return
    }

    if let value = response.result.value {
        print("The email is: \(value)" )
    }
}
Run Code Online (Sandbox Code Playgroud)

如果有人弄错了我做错了什么.谢谢!!

Hir*_*ahi 5

您使用的是哪种版本的alamofire?请尝试使用URLEncoding.default而不是JSONEncoding.default.