comparison 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
comparison
equal deleted inserted replaced
449:4255f94d0767 450:4b8031e696e8
4 // 4 //
5 // Created by Dennis Concepción Martín on 7/5/21. 5 // Created by Dennis Concepción Martín on 7/5/21.
6 // 6 //
7 7
8 import SwiftUI 8 import SwiftUI
9 import Bazooka 9 import Alamofire
10 10
11 class Profile: ObservableObject { 11 class Profile: ObservableObject {
12 @Published var showView = false 12 @Published var showView = false
13 @Published var data = ProfileResponse() 13 @Published var data = ProfileResponse()
14 14
15 func request(_ url: String, _ requestType: RequestType) { 15 func request(_ url: String, _ requestType: RequestType) {
16 let bazooka = Bazooka() 16 AF.request(url).responseDecodable(of: ProfileResponse.self) { response in
17 bazooka.request(url: url, model: ProfileResponse.self) { response in 17 if let value = response.value {
18 switch requestType { 18 switch requestType {
19 case .initial: 19 case .initial:
20 self.data = response 20 self.data = value
21 default: 21 default:
22 self.data = response 22 self.data = value
23 }
24
25 self.showView = true
23 } 26 }
24
25 self.showView = true
26 } 27 }
27 } 28 }
28 } 29 }