Mercurial > public > lazybear
diff LazyBear/Views/Profile/Networking/Profile.swift @ 450:4b8031e696e8
Change Bazooka to Alamofire
Alamofire is compatible with WatchOS and MacOS
author | Dennis Concepción Martín <dennisconcepcionmartin@gmail.com> |
---|---|
date | Sat, 26 Jun 2021 16:36:53 +0200 |
parents | 4effac4733b0 |
children |
line wrap: on
line diff
--- a/LazyBear/Views/Profile/Networking/Profile.swift Wed Jun 23 13:03:00 2021 +0200 +++ b/LazyBear/Views/Profile/Networking/Profile.swift Sat Jun 26 16:36:53 2021 +0200 @@ -6,23 +6,24 @@ // import SwiftUI -import Bazooka +import Alamofire class Profile: ObservableObject { @Published var showView = false @Published var data = ProfileResponse() func request(_ url: String, _ requestType: RequestType) { - let bazooka = Bazooka() - bazooka.request(url: url, model: ProfileResponse.self) { response in - switch requestType { - case .initial: - self.data = response - default: - self.data = response + AF.request(url).responseDecodable(of: ProfileResponse.self) { response in + if let value = response.value { + switch requestType { + case .initial: + self.data = value + default: + self.data = value + } + + self.showView = true } - - self.showView = true } } }