Вы можете попробовать, как показано ниже
Alamofire.request(urlRequest,headers:headers).validate()
.responseJSON {
response in
guard response.response?.statusCode != 403 else
{
print("Session expired, Must relogin")
return
}
guard response.response?.statusCode != 500 else
{
print("Something Went wrong, please refresh")
return
}
guard response.response?.statusCode != 504 else
{
Print("Gateway timeout, Please refresh")
return
}
switch response.result {
case .success:
do{
let marketChart = try JSONDecoder().decode(data.self, from:response.data!)
completionHandler(self.array, nil)
}
catch {
completionHandler(nil, error)
}
case .failure(let error):
print(error.localizedDescription)
completionHandler(nil, error)
}
}