当我在使用AlamoFire的POST时,其中一个String参数添加了字符吗?有想法吗?
let email = emailText.text
Alamofire.request("https://xxxx", method: .post, parameters: ["subscribed": true,"address": email],encoding: URLEncoding.httpBody, headers: headers).validate()
.log().responseJSON {
response in
这是参数的样子
address=Optional%28%22Adam%40yahoo.com%22%29&subscribed=1
这是我将电子邮件硬编码到
时的样子let email = "adam@yahoo.com"
结果
address=adam%40yahoo.com&subscribed=1
答案 0 :(得分:0)
问题是您的email
被包装到一个可选的(空值)中。您可能要先将其拆开:
guard let email = emailText.text else {
// Handle the case where there is no email
return
}
...