Skip to content

Instantly share code, notes, and snippets.

@wadheraswati
Last active November 9, 2019 14:16
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 wadheraswati/d3d3d95c9144e857ebc7a1c36eaf2548 to your computer and use it in GitHub Desktop.
Save wadheraswati/d3d3d95c9144e857ebc7a1c36eaf2548 to your computer and use it in GitHub Desktop.
Alamofire request method
func requestWith(url: URL, method: HTTPMethod, parameters: Parameters? = nil, headers: HTTPHeaders? = nil, completion: (DataResponse) -> (Void), failure: (Data) -> (Void))
let request = Alamofire.request(url,
method: method,
parameters: parameters,
headers : headers)
request.validate().responseJSON {
response in
if (200..<300) ~= response.response?.statusCode {
completion(response.result)
} else {
failure(response.data)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment