【发布时间】:2016-12-31 19:20:17
【问题描述】:
我正在使用 Alamofire 调用我的 API。
下面是代码。
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)
以下是我在邮递员应用程序中的响应。
有人可以帮忙吗
【问题讨论】: