0
我正在使用Alamofire来调用我的API。POST请求不能在swift3中使用alamofire
以下是代码。
func alamofirePost() {
let headers: HTTPHeaders = [ "content-type": "x-www-form-urlencoded"]
let todosEndpoint: String = "http://54.244.108.186:4000/api/post_upc"
let newTodo: [String: Any] = ["UPC": codeTextView.text, "DATE_TIME": currentTime() ]
print("i am in alamo")
Alamofire.request(todosEndpoint, method: .post, parameters: newTodo ,encoding: JSONEncoding.default,headers: headers)
.responseJSON { response in
guard response.result.error == nil else {
// got an error in getting the data, need to handle it
print("error calling POST on /todos/1")
print(response)
print(response.result.error!)
return
}
当我调用的函数,它试图在数据库
INSERT INTO `UPC`(`UPC`,`DATE_TIME`) VALUES (NULL,NULL)
下面插入空值是响应,当我在邮递员应用进行操作。
能有人帮
大科迪发送。谢谢。我研究并得到了解决方案。 – Uyyan