Created
August 31, 2022 10:15
-
-
Save erdemildiz/60f05906c9be0bfe74ad617a919fb92f to your computer and use it in GitHub Desktop.
Async&Await Syntax
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 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