Mercurial > public > lazybear
changeset 328:240b88e3e53e
Testing networking in HomeView
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Tue, 30 Mar 2021 23:14:53 +0200 |
parents | b39399c3c7cf |
children | 6576d259c8c8 |
files | LazyBear/Views/Networking/HomeData.swift |
diffstat | 1 files changed, 21 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /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 } + } +}