aboutsummaryrefslogtreecommitdiff
path: root/foray/Presenters
diff options
context:
space:
mode:
Diffstat (limited to 'foray/Presenters')
-rw-r--r--foray/Presenters/PenguinItemPresenter.swift9
1 files changed, 3 insertions, 6 deletions
diff --git a/foray/Presenters/PenguinItemPresenter.swift b/foray/Presenters/PenguinItemPresenter.swift
index 1d617bf..45b970c 100644
--- a/foray/Presenters/PenguinItemPresenter.swift
+++ b/foray/Presenters/PenguinItemPresenter.swift
@@ -16,12 +16,9 @@ class PenguinItemPresenter {
let fetcher = ForayFetcher()
func fetch() async -> [PenguinItemViewModel] {
- do {
- let apiItems: [PenguinItemModel] = try await fetcher.fetch(url: Constants.apiEndpoint)
- return transform(models: apiItems)
- } catch {
- return []
- }
+ guard let endpoint = URL(string: Constants.apiEndpoint),
+ let apiItems: [PenguinItemModel] = try? await fetcher.fetch(url: endpoint) else { return [] }
+ return transform(models: apiItems)
}
func transform(models: [PenguinItemModel]) -> [PenguinItemViewModel] {