I am running the following code and it keeps getting an error saying that found nil while unwrapping an optional. What am I doing wrong? I am using a good API.
Code Block language class Database_2020 { static let shared = Database_2020() var leagueNames: [String] var leagues: [[String]] let url = " https://www.someURL.com/service/" private func getData(from url: String) { let task = URLSession.shared.dataTask(with: URL(string: url)!) { data, response, error in guard let data = data, error == nil else print("something went wrong") return } var result: Response? do { result = try JSONDecoder().decode(Response.self, from: data) } catch { print("failed to convert \(error.localizedDescription)") } guard let json = result else { return } print(json.status) print(json.results.draftPosition) print(json.results.name) } task.resume() func printData() { getData(from: url) } }