Slide 26
Slide 26 text
struct RandomFox: Equatable, Codable { let image: String; let link:
String}
Task {
let url = URL(string: "https://randomfox.ca/floof/")!
let request = URLRequest(url: URL(string: "https://randomfox.ca/
floof")!, cachePolicy: .reloadIgnoringLocalCacheData)
do {
let (data, response) = try await URLSession.shared.data(for:
request)
_ = response as! HTTPURLResponse
let randomFox = try JSONDecoder().decode(RandomFox.self, from:
data)
} catch error {
print("error=\(error.localizedDescription)")
}
}