diff --git a/Features/Sources/APIClientLive/LiveKey.swift b/Features/Sources/APIClientLive/LiveKey.swift index bd8e597..883f477 100644 --- a/Features/Sources/APIClientLive/LiveKey.swift +++ b/Features/Sources/APIClientLive/LiveKey.swift @@ -7,7 +7,7 @@ import Models extension APIClient: DependencyKey { private static let apiKeyClient = APIKeyClient.liveValue - + public static var liveValue: Self { .init( apod: { @@ -19,16 +19,16 @@ extension APIClient: DependencyKey { } ) } - + private static func request(to path: String) async throws -> (Data, URLResponse) { let baseURL = URL(string: "https://api.nasa.gov")! - + var urlComponents = URLComponents(url: baseURL, resolvingAgainstBaseURL: false)! urlComponents.path = "/planetary/\(path)" urlComponents.queryItems = [ URLQueryItem(name: "api_key", value: apiKeyClient.getKey()?.rawValue) ] - + return try await URLSession.shared.data(from: urlComponents.url!) } } diff --git a/Features/Sources/Settings/APIKey/APIKeySetting.swift b/Features/Sources/Settings/APIKey/APIKeySetting.swift index 7ae239d..10622c0 100644 --- a/Features/Sources/Settings/APIKey/APIKeySetting.swift +++ b/Features/Sources/Settings/APIKey/APIKeySetting.swift @@ -26,7 +26,7 @@ public struct APIKeySetting { case onAppear case setAPIKeyInput(String) case updateButtonTapped - + @CasePathable public enum Delegate { case updated @@ -41,7 +41,7 @@ public struct APIKeySetting { switch action { case .delegate: return .none - + case .onAppear: state.apiKeyInput = apiKeyClient.getKey() ?? .init(rawValue: "") return .none