Get immediate access to this and over 1,500+ other videos and books.

Boost your skills with a Beginner subscription. With over 60+ video courses and our core foundational programming books bundled in one subscription, it’s simply the best investment you can make in your development career.

Challenge: Fetch Data Over the Network

In this challenge episode you will put your existing knowledge about URLSession to the test in order to download and display data downloaded from the network.


Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a Professional subscription.

Welcome to the seventh episode! Time for a little challenge for you.

let configuration = URLSessionConfiguration.default
let session = URLSession(configuration: configuration)
Task {

Task {
  let (data, response) = try await url)
guard let httpResponse = response as? HTTPURLResponse,
else {
  throw MediaError.requestFailed
guard let mediaResponse = try? JSONDecoder().decode(MediaResponse.self, from: data) else {
  throw MediaError.responseDecodingFailed
await {
  musicItems = mediaResponse.results