Reputation: 6608
I currently try to get a json but i always get a error
Alamofire.request(.GET, "http://api.androidhive.info/contacts/").responseJSON { (req, res, json) -> Void in
let swiftyJsonVar = JSON(json.value!)
print(swiftyJsonVar)
}
Upvotes: 0
Views: 82
Reputation: 294
try this
Alamofire.request("http://api.androidhive.info/contacts/").responseJSON { (responseObject) -> Void in
if responseObject.result.isSuccess {
let resJson = JSON(responseObject.result.value!)
print(resJson)
}
}
Upvotes: 0
Reputation: 6608
Alamofire.request(.GET, "http://api.androidhive.info/contacts/").responseJSON { (responseData) -> Void in
let swiftyJsonVar = JSON(responseData.result.value!)
print(swiftyJsonVar)
Upvotes: 0
Reputation: 285059
The error message reveals that the return type of the closure is a single object rather than three.
Two suggestions to get the proper syntax quickly:
In your case the request
method returns one response
object
Upvotes: 1