Skip to content

Instantly share code, notes, and snippets.

@JohnSundell
Last active March 27, 2017 16:39
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 JohnSundell/ed6ea256dcf94da1678f81a28c6d0bca to your computer and use it in GitHub Desktop.
Save JohnSundell/ed6ea256dcf94da1678f81a28c6d0bca to your computer and use it in GitHub Desktop.
func loadSearchData(matching query: String) throws -> Data {
let urlString = "https://my.api.com/search?q=\(query)"
guard let url = URL(string: urlString) else {
throw SearchError.invalidQuery(query)
}
return try Data(contentsOf: url)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment