Created
May 31, 2021 07:42
-
-
Save alfianlosari/a447afec492aab8a4715241696bd2029 to your computer and use it in GitHub Desktop.
Async Main with GroupTask
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
// 1 | |
static func main() async { | |
do { | |
// 2 | |
let revengeOfSith: SWAPIResponse<Film> = try await fetchAPI(url: Film.url(id: "6")) | |
print("Resp: \(revengeOfSith.response)") | |
// 3 | |
let urlsToFetch = Array(revengeOfSith.response.characterURLs.prefix(upTo: 3)) | |
let revengeOfSithCharacters: [SWAPIResponse<People>] = try await fetchAPIGroup(urls: urlsToFetch) | |
print("Resp: \(revengeOfSithCharacters)") | |
} catch { | |
// 4 | |
print(error.localizedDescription) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment