Last active
September 24, 2021 01:32
-
-
Save gtokman/1d5bff38b7bd67b06504aa790cc6e322 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@State var businesses = [Bussiness]() | |
NavigationView { | |
List { | |
ForEach(businesses) { business in | |
Text(business.name ?? "no name") | |
} | |
} | |
.listStyle(.plain) | |
.navigationTitle(Text("Boston")) | |
// Run async code straight from the view | |
.task { | |
do { | |
let (data, _) = try await session.data(for: request) | |
let result = try JSONDecoder().decode(SearchResult.self, from: data) | |
self.businesses = result.businesses | |
} catch { | |
print(error.localizedDescription) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment