Last active
October 14, 2020 10:10
-
-
Save aalemi97/6d0fa73f1ce12e8cbb4f5f4e32c51cdb to your computer and use it in GitHub Desktop.
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
func request(_ url: String, method: HTTPMethod = .get, parameters: Parameters? = nil, | |
encoding: ParameterEncoding = URLEncoding.queryString, headers: HTTPHeaders? = nil, | |
interceptor: RequestInterceptor? = nil, completion: @escaping completionHandler) { | |
AF.request(url, method: method, parameters: parameters, encoding: encoding, | |
headers: headers, interceptor: interceptor ?? self).validate().responseJSON { (response) in | |
if let data = response.data { | |
completion(.success(data)) | |
} else { | |
completion(.failure(.unavailableServer)) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment