Last active
June 7, 2022 18:35
-
-
Save robertmryan/6e59f99c7fe2551581433cb1786dc245 to your computer and use it in GitHub Desktop.
This file contains 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
func search() async throws -> BusinessSearchResult { | |
var components = URLComponents(string: "https://api.yelp.com/v3/businesses/search") | |
components?.queryItems = [ | |
URLQueryItem(name: "term", value: "theater"), | |
URLQueryItem(name: "location", value: "NYC") | |
] | |
guard let url = components?.url else { throw URLError(.badURL) } | |
let (data, _) = try await session.data(from: url) | |
return try JSONDecoder().decode(BusinessSearchResult.self, from: data) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment