Skip to content

Instantly share code, notes, and snippets.

@erdemildiz
Created August 31, 2022 10:15
Show Gist options
  • Save erdemildiz/60f05906c9be0bfe74ad617a919fb92f to your computer and use it in GitHub Desktop.
Save erdemildiz/60f05906c9be0bfe74ad617a919fb92f to your computer and use it in GitHub Desktop.
Async&Await Syntax
func fetchPerson(by userId: String) async -> Person {
do {
// Tell compiler wait for the result with `await` keyword
let (data, response) = try await URLSession.shared.data(from: <URL>)
} catch {
// ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment