"VOODO and Creating the UI" apiService Error

I am following Stewart Lynch’s excellent second video in the concurrency series and encountering an issue when calling the apiService.

Stewart’s code can be seen at this timestamp https://youtu.be/_tnbwaHpJpM?t=321

My code is here github. Relevant files are:

  • APIService
  • UsersListViewModel (error is here)
  • Models [Users, Posts]

(the forum wouldn’t allow me to post more than 2 links, so I couldn’t separate them – sorry about that!)

The error messages read:

  • Cannot convert value of type '(Result<[User], APIError>) -> Void' to expected argument type '(Result<[User], Error>) -> Void'
  • Cannot convert value of type '(Result<[User], APIError>) -> Void' to expected argument type '(Result<[User], Error>) -> Void'

I reviewed video 1 to ensure the User struct matched. The APIError is referencing a valid Error type. And the function isn’t returning anything, so it satisfied Void. I’m stumped! Is anyone else experiencing this?

In your DataService code there is an error in your getJSON function signature.

Where you have:

.....completion: @escaping (Result<T, Error>) -> Void) {

It needs to be:

.....completion: @escaping (Result<T, APIError>) -> Void) {
1 Like

Wow, thanks @Chris_Parker! Right in front of me the whole time, of course.

Much appreciated. Very grateful for your support.