【发布时间】:2016-03-08 10:05:53
【问题描述】:
我需要向我的应用程序的 API 发送登录请求,我没有编写 API 代码,有人正在为我们做这件事,所以我使用邮递员来测试请求并使用邮递员执行此操作:
URL : {{dev}}/customer/login-mock
Body / x-www-form-urlencoded :
key = toto / value = toto
key = toto / value = toto
有了这个我得到了回应。
但我不知道如何用 Alamofire 实现它。我有点迷茫,我看到的所有教程都是使用 url 参数将参数发送到他们的 api。
我可以使用类似的函数:
RequestManager.request(.POST, "customer/login-mock", body: [username: "toto", password: "toto"])
class RequestManager: NSObject {
request(method, url, body) {
Alamofire.request(someRequest).responseJSON{response in ....}
}
}
感谢您的帮助!
【问题讨论】: