Downloading Image from url doesn't work

I'm trying to get some data from a json Api and display this data along with an image. First I have a function that fetches the data from the Api, then I have another function that downloads the image data. The problem is that the second function doesn't seem to be working right and the image data is never recieved.

Code Block
func fetchAPI() {
        URLSession.shared.dataTask(with: url) { (data, response, error) in
/* Code that decodes the json and gets the imageURL string */
                DispatchQueue.main.async {
                    self.downloadImage(url: imageURL)
                }
            } catch {
                print("Error: \(error.localizedDescription)")
            }
        }
        .resume()
    }

The function that downloads the image:

Code Block
 func downloadImage(url: String) {
        print("Downloading Image...")
        guard let imageURL = URL(string: url) else {
            print("Error: Invalid image URL")
            return
        }
        URLSession.shared.dataTask(with: imageURL) { data, response, error in
            guard let recievedData = data, error == nil  else {
                print("Error: No Data")
                return
            }
                        print("Got Data") <- Doesn't output to console
print(recievedData) <- Doesn't output to console
            DispatchQueue.main.async {
                self.imageData = recievedData <- Nothing
            }
        }
    }


What do you get with all the prints in your code?
Downloading Image from url doesn't work
 
 
Q