问题
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