Please help with the question. How do I transfer data received using a request to the rest api to SwiftUI so that I can output it in the emulator?
URLSession.shared.dataTask(with: url) { data, _, _ in
guard let data = data else { return }
do {
let users = try JSONDecoder().decode([User].self, from: data)
for user in users {
print(user.title)
}
} catch let error {
print(error)
}
}.resume()
How do i access the users array in view?