Skip to content

Instantly share code, notes, and snippets.

@robertmryan
Last active June 7, 2022 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertmryan/6e59f99c7fe2551581433cb1786dc245 to your computer and use it in GitHub Desktop.
Save robertmryan/6e59f99c7fe2551581433cb1786dc245 to your computer and use it in GitHub Desktop.
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