Group Group Group Group Group Group Group Group Group

Chapter 12. Creating a Simple iPhone App

I am following the book on Vapor here by doing the whole book project from the start myself and now I get the following error in my getAll(completion:) function in ResourceRequest.swift that is supposed to be used for values fetching: “Cannot find type “ResourceRequestError” in scope”. The function looks like this:

`// get all values, takes completion closure as parameter
func getAll(completion: @escaping (Result<[ResourceType], ResourceRequestError>) -> Void) {
// create data task with resource url
let dataTask = URLSession.shared.dataTask(with: resourceURL) { data, _, _ in
// ensure response returns some data, otherwise call completion with failure case
guard let jsonData = data else {
completion(.failure(.noData))
return
}

        do {
            // decode response data
            let resources = try JSONDecoder()
                .decode(
                    [ResourceType].self,
                    from: jsonData)
            // call completion with .success case
            completion(.success(resources))
        } catch {
            // catch errors
            completion(.failure(.decodingError))
        }
    }
    // start data task
    dataTask.resume()
}`

I went through the starter project files and cannot seem to find where the type is defined there either.

There error is defined here vpr-materials/ResourceRequestError.swift at editions/3.0 · raywenderlich/vpr-materials · GitHub

Thank you! This helped.