Deployd comparison and swift with alamofire

喜你入骨 提交于 2019-12-25 02:59:31

问题


I am trying to query data from my Deployd API with alamofire. How is it possible to do a comparison in a request. I have something like:

let parameters = ["number": ["gt": 3]]
 Manager.sharedInstance.request(.GET, "http://localhost:2403/collections", parameters: parameters).responseJSON { (request, response, result) -> Void in
            print(result.isSuccess)
            print(result.data)
        }

But the result is empty. In my dashboard i have a number column with the values: 1,2,3 and 4. So the response should return me the rows with the number 4.

Any ideas? Thank


回答1:


You need to extract the value instead of the data. In Alamofire 2.0, the data is only available in a .Failure case. This has all been redesigned in Alamofire 3.0 which leverages a Response object instead.

let parameters = ["number": ["gt": 3]]
let URLString = "http://localhost:2403/collections"

Manager.sharedInstance.request(.GET, URLString, parameters: parameters)
    .responseJSON { (request, response, result) -> Void in
        print(result.isSuccess)
        print(result.data)
        print("JSON: \(result.value)")
        print("Error: \(result.error)")
    }


来源:https://stackoverflow.com/questions/32950615/deployd-comparison-and-swift-with-alamofire

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!