Skip to content

Instantly share code, notes, and snippets.

Created August 26, 2016 07:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/6698fc40f2be33c069a7313237e7c1c7 to your computer and use it in GitHub Desktop.
Save anonymous/6698fc40f2be33c069a7313237e7c1c7 to your computer and use it in GitHub Desktop.
//POST Request
class func requestPOSTURL (strURL: String, params: [String : AnyObject]?, headers: [String : String]?, success: (JSON) -> Void, failure:(NSError) -> Void){
Alamofire.request(.POST,strURL, parameters: params, encoding: ParameterEncoding.JSON, headers: headers).responseJSON { (responseObject) -> Void in
// print(responseObject)
if responseObject.result.isSuccess{
let resJson = JSON(responseObject.result.value!)
success(resJson)
}
if responseObject.result.isFailure{
let error: NSError = responseObject.result.error!
failure(error)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment