Created
July 2, 2021 15:13
-
-
Save pietrorea/a47f348cb25f2aae71d9f916e8b5326d to your computer and use it in GitHub Desktop.
Alamofire 5.43 `responseDecodable` example
This file contains hidden or 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 load(_ entityId: Int, completion: @escaping ( (SampleServiceResponse?) -> Void)) { | |
let urlString = "https://api.sweetpeamobile.com/v1/sampleService?locationId=\(locationId)" | |
AF.request(urlString).responseDecodable(of: SampleServiceResponse.self) { response in | |
switch response.result { | |
case .success(let decodedResponse): | |
completion(decodedResponse) | |
case .failure(let error): | |
print("Networking error: \(error.localizedDescription)") | |
completion(nil) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment