# HG changeset patch # User Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> # Date 1617138893 -7200 # Node ID 240b88e3e53eaa2922ffdbc28485cf5ae777ad12 # Parent b39399c3c7cfa76b0d641e43faef60a16fde8027 Testing networking in HomeView diff -r b39399c3c7cf -r 240b88e3e53e LazyBear/Views/Networking/HomeData.swift --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LazyBear/Views/Networking/HomeData.swift Tue Mar 30 23:14:53 2021 +0200 @@ -0,0 +1,21 @@ +// +// HomeData.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 30/3/21. +// + +import SwiftUI + +class HomeData: ObservableObject { + @Published var sectorPerformance = [SectorPerformanceModel]() { didSet { print(sectorPerformance) }} + + + let baseUrl = Bundle.main.infoDictionary?["IEX_URL"] as? String ?? "Empty url" + let apiKey = Bundle.main.infoDictionary?["IEX_API"] as? String ?? "Empty key" + + func getSectorPerformance() { + let url = "\(baseUrl)/stock/market/sector-performance?token=\(apiKey)" + request(url: url, model: [SectorPerformanceModel].self) { self.sectorPerformance = $0 } + } +}