LAST CHANCE: Save 50% on all my Swift books and bundles! >>

"Fetch error" in HWS SwiftUI edition in Chapter 10 - Cupcake Corner

Forums > Books

When I run the code to retreive the Taylor Swift song list in the initial part of the chapter what I see in the console is Fetch error: Unknown error and no data is retrieved!

I have checked the code over and over again and I've checked the URL. All is correct as far as I can tell, but just the error.

Have others had any issues? Does yours work?

And yes, .resume() is in the code for the URLSession!

Any help gratefully appreciated.


Hey, would you mind uploading your code to Github and posting the link so we can check it out? Thanks


Thanks very much for your offer. I've never loaded anything onto Github so I'll have to work out how to do it first - a useful excersise in itself!

I continued with the rest of the chapter and coded the rest of it which makes the URL request and displays the returned JSON and that all just works fine.

I will see about uploading the code - hold on to your hat. :-)


I received this error message as well. Turns out I had typed "trackID" instead of "trackId" in the code. If you paste the URL in Safari, if the URL is correct you'll get a downloaded file.

You can add a print in the URLSession call to see if you're getting data from the request as well like this:

if let data = data {
            print(data) // will print nnnnn bytes if data received



Always double-check the spelling of the keys. Every key you declare must exactly match a key in the data. Even the smallest misspelling will cause a failure without any explanation.

I check the keys by retrieving the url with a browser and comparing my keys to the keys in the text file that is downloaded.


Click here to save 50% on all my books and bundles!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.