Mercurial > public > lazybear
changeset 170:2dc7d0b855d6
Test SearchApi
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Sat, 20 Feb 2021 13:10:04 +0100 |
parents | 66f8783d1e2d |
children | 6c47d21f94ae |
files | LazyBear/Tests/TestSearchAPI.swift |
diffstat | 1 files changed, 16 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/LazyBear/Tests/TestSearchAPI.swift Sat Feb 20 13:09:44 2021 +0100 +++ b/LazyBear/Tests/TestSearchAPI.swift Sat Feb 20 13:10:04 2021 +0100 @@ -8,8 +8,23 @@ import SwiftUI struct TestSearchAPI: View { + @State private var companies = [CompanyModel]() + var body: some View { - Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + Button(action: { print(companies) }) { + Text("Print companies") + } + .onAppear { + request(url: getUrl(), model: [CompanyModel].self) { self.companies = $0 } + } + } + + private func getUrl() -> String { + let baseUrl = Bundle.main.infoDictionary?["IEX_URL"] as? String ?? "Empty url" + let apiKey = Bundle.main.infoDictionary?["IEX_API"] as? String ?? "Empty key" + let url = "\(baseUrl)/search/apple?token=\(apiKey)" + + return url } }