Last active
August 20, 2021 07:48
-
-
Save Rashidium/73b44552054e357fa826a77568cea3aa 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
import Alamofire | |
... | |
func login() { | |
let urlStr = "\(serverUrl)\(EndpointTails.login.rawValue)" | |
AF.request(urlStr, method: .get).responseDecodable { (response: DataResponse<PanpaResponse<User>, AFError>) in | |
if let panpaResponse = response.value { | |
switch panpaResponse.status { | |
case .success: | |
guard let user: User = panpaResponse.data else { return } | |
print(user.username) | |
case .failed: | |
print("API error with message: \(panpaResponse.message)") | |
} | |
} else { | |
let errorResponse = PanpaResponse<User>() | |
print("API error with message: \(errorResponse.message)") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment