i have run this code but not print any data in console and not get data in my api so no data display in may simulators
func downloadJSON(completed: @escaping () -> ()){
let url = URL(string: "https://gydo.me/api/api/User/index")
URLSession.shared.dataTask(with: url!) {data, response, error in
guard let data = data, error == nil else {return}
//print(data)
if error == nil {
do{
if let json = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]{
print(json)
self.detail = try JSONDecoder().decode([apiData].self, from: data)
DispatchQueue.main.async {
completed()
}
}
}catch{
print("JSON Error")
}
}
}.resume()
}
}
func downloadJSON(completed: @escaping () -> ()){
let url = URL(string: "https://gydo.me/api/api/User/index")
URLSession.shared.dataTask(with: url!) {data, response, error in
guard let data = data, error == nil else {return}
//print(data)
if error == nil {
do{
if let json = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]{
print(json)
self.detail = try JSONDecoder().decode([apiData].self, from: data)
DispatchQueue.main.async {
completed()
}
}
}catch{
print("JSON Error")
}
}
}.resume()
}
}