Last active
November 9, 2019 14:00
-
-
Save wadheraswati/5169be96922ab034ca31d9ec5e589d9b to your computer and use it in GitHub Desktop.
Network Layer with Alamofire
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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