Bronze solution for Ch20

Modify fetchInterestingPhotos as follows:

func fetchInterestingPhotos(completion: @escaping (PhotosResult) -> Void) {
    
    let url = FlickrAPI.interestingPhotosURL
    let request = URLRequest(url: url)
    let task = session.dataTask(with: request) {
        (data, response, error) -> Void in
        
        
        if let httpStatus = response as? HTTPURLResponse {
            //check for http errors
            print("fetchInterestingPhotos")
            print("statusCode is \(httpStatus.statusCode)")
            print("Header fields are \(httpStatus.allHeaderFields)")
        }
        
        
        let result = self.processPhotosRequest(data: data, error: error)
        
        OperationQueue.main.addOperation {
            completion(result)
        }
    }
    
    task.resume()
}

Modify fetchImage as follows:

func fetchImage(for photo: Photo, completion: @escaping (ImageResult) -> Void) {
    
    let photoURL = photo.remoteURL
    let request = URLRequest(url: photoURL)
    
    let task = session.dataTask(with: request) {
        (data, response, error) -> Void in
        
        if let httpStatus = response as? HTTPURLResponse {
            //check for http errors
            print("fetchImage:")
            print("statusCode is \(httpStatus.statusCode)")
            print("Header fields are \(httpStatus.allHeaderFields)")
        }
        
        let result = self.processImageRequest(data: data, error: error)
        
        
        OperationQueue.main.addOperation {
            completion(result)
        }
        
    }
    task.resume()
}

Works great! thanks!