From 6a00d23769744c38eb2f84140d280dbacadba4f0 Mon Sep 17 00:00:00 2001 From: Valerio Date: Wed, 26 Jul 2023 11:20:25 +0200 Subject: [PATCH] Update README.md --- README.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index dba56b1..0c800ac 100644 --- a/README.md +++ b/README.md @@ -96,16 +96,14 @@ Equivalent of https://api.example.com/person with the following body: **API CALL** -- Using Closures +- Using async/await ```swift -network.request(with: endpoint) { (response) in - switch response.result { - case .success(let person): - print("Success! \(person.name)") - case .failure(let error): - print(error.localizedDescription) - } +do { + let response = try await network.request(with: endpoint) + print(response) +} catch { + print(error) } ``` @@ -128,13 +126,15 @@ network.request(with: endpoint)? .store(in: &subscriptions) ``` -- Using async/await +- Using Closures ```swift -do { - let response = try await network.request(with: endpoint) - print(response) -} catch { - print(error) +network.request(with: endpoint) { (response) in + switch response.result { + case .success(let person): + print("Success! \(person.name)") + case .failure(let error): + print(error.localizedDescription) + } } ```