Skip to content

Instantly share code, notes, and snippets.

@wadheraswati
Last active November 9, 2019 14:00
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/5169be96922ab034ca31d9ec5e589d9b to your computer and use it in GitHub Desktop.
Save wadheraswati/5169be96922ab034ca31d9ec5e589d9b to your computer and use it in GitHub Desktop.
Network Layer with Alamofire
static func request(urlRequest: URLRequest, completion: (DataResponse) -> (Void), failure: (Data) -> (Void)) {
let request = Alamofire.request(urlRequest)
.validate()
request.validate().responseJSON {response in
if (200..<300) ~= response.response?.statusCode {
completion(response.result)
} else {
failure(response.data)
}
}
return response
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment