Reputation:
I've tried to implement JSON Parsing in my App to see the latest Wordpress Posts from my website.
Now i have the following error:
"Contextual type for closure argument list expects 1 argument, but 3 were specified"
The "Problem Code"
func getPosts(getposts : String)
{
Alamofire.request(.GET, getposts, parameters:parameters)
.responseJSON { request, response, result in
switch result
{
case .Success(let data):
self.json = JSON(data)
self.tableView.reloadData()
case .Failure(let error):
print("Request failed with error: \(error)")
}
}
}
Hope you can help me (:
Best regards!
Upvotes: 1
Views: 1403
Reputation: 8782
Simple code which takes Base URL and Parameter to service and method type.
Alamofire.request(.POST, "http://www.abc.cpm", parameters: ["consumer_key": "fnfkdkdndf"]).responseJSON { response in
print(response)
}
Upvotes: 0
Reputation:
I Got it !
func getPosts(getposts : String)
{
Alamofire.request(.GET, getposts, parameters:parameters)
.responseJSON { response in
guard let data = response.result.value else{
print("Request failed with error")
return
}
self.json = JSON(data)
self.tableView.reloadData()
}
}
Upvotes: 3