I am trying to retrieve the videos from my Youtube Playlist but it throws an error debugDescription: "Cannot get KeyedDecodingContainer -- no value found for key CodingKeys(stringValue: "url", intValue: nil) ("url")", underlyingError: nil))))Here is how my VideoModel is structured
import Alamofireclass VideoModel: ObservableObject { @Published var videos = [Video]() init() { getVideos() } func getVideos() { // Create URL Obj guard let url = URL(string: "\(Constants.API_URL)/playlistItems") else { return } // Get a decoder let decoder = JSONDecoder() decoder.dateDecodingStrategy = .iso8601 // Create URL request AF.request( url, parameters: ["part": "snippet", "playlistId": Constants.PLAYLIST_ID, "key": Constants.API_KEY] ) .validate() .responseDecodable(of: Response.self, decoder: decoder) { response in // Check that the call was successful switch response.result { case .success: break case .failure(let error): // print(error.localizedDescription) debugPrint(error) return } // update the UI with videos if let items = response.value?.items { DispatchQueue.main.async { self.videos = items }
How can I fix this? Thank you