I created a class and a function to make an API call and return some data. I get the data back in the console, but I'm not able to use the data and I think it's because I'm not completing the data correctly. The data being returned is surrounded by { } instead of [ ].
The function looks like this:
At completion(yelpbusinessinfo!) I get the following error in the compiler and I'm assuming it has to do with how the data is being returned.
Cannot convert value of type 'Welcome' to expected argument type '[Welcome]'
Any help on what the proper format should be?
The function looks like this:
Code Block func getBusinessInfo(completion: @escaping ([Welcome]) -> ()) { ... let task = URLSession.shared.dataTask(with: request) { (data, response, error) in ... if let yelpbusinessinfo = data { let decoder = JSONDecoder() let yelpbusinessinfo = try? decoder.decode(Welcome.self, from: yelpbusinessinfo) print(yelpbusinessinfo?.reviews[1].text) completion(yelpbusinessinfo!) }
At completion(yelpbusinessinfo!) I get the following error in the compiler and I'm assuming it has to do with how the data is being returned.
Cannot convert value of type 'Welcome' to expected argument type '[Welcome]'
Any help on what the proper format should be?